当尝试在控制台中使用任何hg mercurial命令时,我一直收到此错误。 我使用自制软件安装了python,并且正在运行Mac Os Catalina v。10.15.1 任何参考将不胜感激。这是我得到的错误:
hg commit --amend
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
File "/usr/local/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
File "/usr/local/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
File "/usr/local/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
File "/usr/local/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
File "/usr/local/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
File "/usr/local/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512
Traceback (most recent call last):
File "/usr/local/bin/hg", line 43, in <module>
dispatch.run()
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 150, in __getattr__
self._load()
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 94, in _load
_origimport, head, globals, locals, None, level)
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 43, in _hgextimport
return importfunc(name, globals, *args, **kwargs)
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/mercurial/dispatch.py", line 625, in <module>
class lazyaliasentry(object):
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/mercurial/dispatch.py", line 636, in lazyaliasentry
@util.propertycache
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 150, in __getattr__
self._load()
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 94, in _load
_origimport, head, globals, locals, None, level)
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 43, in _hgextimport
return importfunc(name, globals, *args, **kwargs)
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/mercurial/util.py", line 180, in <module>
'md5': hashlib.md5,
File "/usr/local/Cellar/mercurial/4.9/lib/python2.7/site-packages/hgdemandimport/demandimportpy2.py", line 151, in __getattr__
return getattr(self._module, attr)
AttributeError: 'module' object has no attribute 'md5'
我也尝试按照此[issue] [1]上的说明进行操作,但似乎没有一种解决方法
brew link openssl --force
Warning: Refusing to link macOS-provided software: openssl@1.1
If you need to have openssl@1.1 first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc
For compilers to find openssl@1.1 you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
For pkg-config to find openssl@1.1 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"
答案 0 :(得分:697)
在我现有的Python 2.7虚拟环境中运行brew reinstall python@2
无效。在它们内部仍然存在ERROR:root:code for hash sha1 was not found
错误。
我运行brew upgrade openssl
后遇到了这个问题。解决方法如下:
$ ls /usr/local/Cellar/openssl
...显示
1.0.2t
根据现有版本,运行:
$ brew switch openssl 1.0.2t
...显示
Cleaning /usr/local/Cellar/openssl/1.0.2t
Opt link created for /usr/local/Cellar/openssl/1.0.2t
然后,在Python 2.7 virtualenv中运行以下命令:
(my-venv) $ python -c "import hashlib;m=hashlib.md5();print(m.hexdigest())"
...显示
d41d8cd98f00b204e9800998ecf8427e
没有更多错误。
答案 1 :(得分:53)
对我来说,这是当我安装Django Web应用程序的依赖项时,会弄乱环境。当我输入cd
时,它会显示相同的错误。
问题是openssl
库,找不到正确的库。
如果您使用的是Macintosh,则可以输入
ls /usr/local/Cellar/openssl
查看所有版本,
brew switch openssl 1.0.XXXX
选择可用的openssl版本。
然后错误消失了:)
答案 2 :(得分:30)
只需卸载python2
$ brew uninstall python@2
如果有任何错误:
$ brew uninstall --ignore-dependencies python@2
答案 3 :(得分:4)
通过首先取消链接openssl来解决此问题
brew unlink openssl
brew reinstall python@2
我还注意到,在运行“ brew doctor”时,在/ usr / local / include / node /中有一个与openssl文件夹有关的警告。我在运行上述命令之前删除了此文件夹(不确定是否相关)
答案 4 :(得分:3)
最近(2020年5月),我在Google的GCP CLI中遇到了此问题。它也可以在过时的Python 2.7上使用。
这是一个令人讨厌的Python 2安装问题。 mBrew不再正确地优雅地安装Python 2,因为没人在乎abondonware。
Conda仍在环境中安装Python 2;我做到了。
答案 5 :(得分:3)
就我而言,我只是使用 pyenv
pyenv uninstall 2.7.18
pyenv install 2.7.18
然后一切似乎都联系起来了。
答案 6 :(得分:2)
下一个解决方案在MacOS Catalina上对我有用:
brew unlink openssl
brew install python@2
安装)brew tap-new <user>/homebrew-python2
brew extract python@2 <user>/homebrew-python2
brew reinstall /usr/local/Homebrew/Library/Taps/<user>/homebrew-python2/Formula/python@2.7.17.rbl
答案 7 :(得分:1)
我的问题是安装了pyenv
并指向旧的python 2版本
卸载python @ 2(自2020年1月1日起python2停产)
$ brew uninstall python@2
Uninstalling /usr/local/Cellar/python@2/2.7.15_1... (4,169 files, 76.0MB)
然后
$ pyenv versions
system
* 2.7.12 (set by /Users/admin/.python-version)
3.4.5
3.7.7
$ pyenv local system
$ pyenv global system
答案 8 :(得分:0)
当我导入hashlib时,会看到一条错误消息,指出未找到哈希md5。
我能够通过首先取消链接openssl来解决此问题: brew取消链接openssl
然后我使用MacPorts卸载了python 2.7: sudo端口卸载python27
然后我使用MacPorts安装了python 2.7: sudo端口安装python27
现在可以导入hashlib了:)
答案 9 :(得分:0)
我的问题是安装了多个版本的python(python仍然是python2的别名,但我希望pip使用python3)。我的系统上还安装了一个python3
垃圾桶
# use pip with python3
$ python3 -m pip install fish
答案 10 :(得分:0)
在macOS Mojave(10.14.6)上,这对我有用:
/usr/local/bin/python
和/usr/local/bin/pip
二进制文件的python
和pip
。答案 11 :(得分:0)
安装openssl
后,我遇到了同样的问题。 answer并没有帮助我,但是在手动链接libcrypto.1.1.dylib
和libssl.1.1.dylib
之后,一切开始起作用。就我而言,是:
ln -s /usr/local/opt/openssl/lib/libcrypto.1.1.dylib /usr/local/lib
ln -s /usr/local/opt/openssl/lib/libssl.1.1.dylib /usr/local/lib
答案 12 :(得分:0)
就我而言,我的环境使用的是 python 2.7.15。当我将 pyenv 版本切换到 2.7.18 时,它就正常工作了。