Saat mencoba menggunakan hg
perintah Mercurial apa pun di konsol, saya terus mendapatkan kesalahan ini. Saya menginstal Python menggunakan Homebrew dan saya menjalankan Mac OS Catalina v. 10.15.1.
Referensi apa pun akan dihargai. Inilah kesalahan yang saya dapatkan:
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'
Saya juga mencoba mengikuti instruksi tentang masalah ini tetapi tidak ada solusi yang tampaknya berhasil
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/[email protected]/bin:$PATH"' >> ~/.zshrc
For compilers to find openssl@1.1 you may need to set:
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
For pkg-config to find openssl@1.1 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
Jawaban:
Menjalankan
brew reinstall python@2
tidak berfungsi untuk lingkungan virtual Python 2.7 yang ada. Di dalam mereka masih adaERROR:root:code for hash sha1 was not found
kesalahan.Saya mengalami masalah ini setelah saya berlari
brew upgrade openssl
. Dan inilah solusinya:...yang menunjukkan
Menurut versi yang ada, jalankan:
...yang menunjukkan
Setelah itu, jalankan perintah berikut dalam Python 2.7 virtualenv:
...yang menunjukkan
Tidak ada lagi kesalahan.
sumber
ls /usr/local/Cellar/openssl
kembali1.0.2s
jadi saya harus menjalankanbrew switch openssl 1.0.2s
Berhasil untuk memperbaikinya dengan membatalkan tautan pertama openssl
Dan kemudian instal ulang python
Saya juga memperhatikan bahwa ketika menjalankan 'brew doctor' ada peringatan terkait dengan folder openssl yang ditemukan di / usr / local / include / node /. Saya menghapus folder ini sebelum menjalankan perintah di atas (tidak yakin jika terkait)
sumber
Kasus saya adalah ketika saya menginstal dependensi aplikasi web Django, itu mengacaukan lingkungan. Saat saya mengetik
cd
, ini menunjukkan kesalahan yang sama.Masalahnya adalah
openssl
perpustakaan, tidak dapat menemukan yang benar.Jika Anda menggunakan Macintosh, Anda dapat mengetik
ls /usr/local/Cellar/openssl
untuk melihat semua versi,
brew switch openssl 1.0.XXXX
untuk memilih versi openssl yang tersedia.
Maka kesalahan hilang :)
sumber
bash ls /usr/local/Cellar/openssl | xargs brew switch openssl
Ketika saya akan mengimpor hashlib saya akan melihat pesan kesalahan yang menyatakan bahwa hash md5 tidak ditemukan.
Saya dapat memperbaiki masalah ini dengan terlebih dahulu memutuskan tautan openssl: brew unlink openssl
Lalu saya uninstall python 2.7 menggunakan MacPorts: sudo port uninstall python27
Kemudian saya menginstal python 2.7 menggunakan MacPorts: sudo port install python27
Sekarang mengimpor hashlib berfungsi :)
sumber
Hapus instalan python2
$ brew uninstall python@2
Jika ada kesalahan:
$ brew uninstall --ignore-dependencies python@2
sumber