[python] hg mercurial 명령을 사용할 때“ERROR : root : code for hash md5를 찾을 수 없습니다”

hg콘솔에서 Mercurial 명령 을 사용하려고 할 때이 오류가 계속 발생합니다. Homebrew를 사용하여 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'

나는 또한이 문제에 대한 지시를 따르려고했지만 해결책이 작동하지 않는 것 같습니다.

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"



답변

brew reinstall python@2기존 Python 2.7 가상 환경에서는 실행 이 작동하지 않았습니다. 그 안에는 여전히 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

더 이상 오류가 없습니다.


답변

먼저 openssl 연결을 해제하여이 문제를 해결했습니다.

brew unlink openssl

그런 다음 파이썬다시 설치하십시오.

brew reinstall python@2

또한 ‘brew doctor’를 실행할 때 / usr / local / include / node /에있는 openssl 폴더와 관련된 경고가 있음을 알았습니다. 위 명령을 실행하기 전에이 폴더를 삭제했습니다 (관련이 있는지 확실하지 않음)


답변

필자의 경우 django 웹 앱의 종속성을 설치할 때 환경이 엉망이된다는 것입니다. 입력 cd하면 동일한 오류가 표시됩니다.

문제는 openssl라이브러리 였습니다 . 올바른 라이브러리를 찾을 수 없습니다.

Macintosh 인 경우 다음을 입력 할 수 있습니다.

ls /usr/local/Cellar/openssl

모든 버전을 보려면

brew switch openssl 1.0.XXXX

사용 가능한 openssl 버전을 선택하십시오.

그런 다음 오류가 사라졌습니다 🙂


답변

hashlib를 가져올 때 hash md5를 찾을 수 없다는 오류 메시지가 표시됩니다.

먼저 openssl을 연결 해제하여이 문제를 해결할 수있었습니다. brew unlink openssl

그런 다음 MacPorts를 사용하여 python 2.7을 제거했습니다. sudo port uninstall python27

그런 다음 MacPorts를 사용하여 python 2.7을 설치했습니다. sudo port install python27

이제 hashlib 가져 오기가 작동합니다 🙂


답변

python2를 제거하십시오.

$ brew uninstall python@2

오류가있는 경우 :

$ brew uninstall --ignore-dependencies python@2


답변