我在尝试检索 hashlib.md5 的签名时遇到异常 功能:
inspect.signature(hashlib.md5)
ValueError: 'usedforsecurity=?' is not a valid parameter name
Python 3.10.8。可能是什么原因以及如何避免这种情况?
这可以追溯到 conda gcc 软件包的安装。根本原因尚不清楚。完整的可重现示例:
# 1. set up new environment
conda create -n pythontest python==3.10
conda activate pythontest
# 2. test python command in fresh environment
python -c "import hashlib, inspect; print(inspect.signature(hashlib.md5))"
# output as expected: (string=b'', *, usedforsecurity=True)
# 3. install gcc
conda install -c conda-forge gcc=12.1.0
# 4. rerun python command
python -c "import hashlib, inspect; print(inspect.signature(hashlib.md5))"
# ValueError: 'usedforsecurity=?' is not a valid parameter name
在我的特定情况下,安装了 gcc,因为 this 答案解决了常见的
'GLIBCXX_3.4.30' not found
错误。
我现在避免使用 this 替代方法安装 gcc。