ImportError: tidak dapat mengimpor nama md5


9

Tidak benar-benar tahu apa yang terjadi di sini, saya perlu menggunakan aplikasi labu saya di beanstalk elastis tetapi entah bagaimana mengubah jalurnya dan tidak dapat menjalankan python application.py lagi

[dotnet --info]
.NET Core SDK (reflecting any global.json):
 Version:   2.1.701
 Commit:    8cf7278aa1

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.701/

Host (useful for support):
  Version: 2.1.12
  Commit:  ccea2e606d

[brew -v]
Homebrew 2.2.0
Homebrew/homebrew-core (git revision 43ad0; last commit 2019-11-30)

Saya sudah melakukan langkah-langkah ini juga:

LDFLAGS:  -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include

Masih mendapat kesalahan ini:

File "/Users/ipchelsea/Library/Python/2.7/lib/python/site-packages/urllib3/util/ssl_.py", line 8, in <module>
    from hashlib import md5, sha1, sha256
ImportError: cannot import name md5

Ketika saya melakukan [brew link --force openssl], saya mendapatkan di bawah:

Warning: Refusing to link macOS-provided software: openssl@1.1

ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.16/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.16/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.16/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.16/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.16/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.16/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.16/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.16/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.16/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.16/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.16/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.16/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 "application.py", line 4, in <module>
    import urllib3
  File "/Users/ipchelsea/Library/Python/2.7/lib/python/site-packages/urllib3/__init__.py", line 8, in <module>
    from .connectionpool import (
  File "/Users/ipchelsea/Library/Python/2.7/lib/python/site-packages/urllib3/connectionpool.py", line 29, in <module>
    from .connection import (
  File "/Users/ipchelsea/Library/Python/2.7/lib/python/site-packages/urllib3/connection.py", line 38, in <module>
    from .util.ssl_ import (
  File "/Users/ipchelsea/Library/Python/2.7/lib/python/site-packages/urllib3/util/__init__.py", line 6, in <module>
    from .ssl_ import (
  File "/Users/ipchelsea/Library/Python/2.7/lib/python/site-packages/urllib3/util/ssl_.py", line 8, in <module>
    from hashlib import md5, sha1, sha256
ImportError: cannot import name md5

Jawaban:


14

Saya menggunakan macOS, perbaiki ini dengan brew unlink openssl && brew reinstall python@2


Terima kasih! itu berhasil
shalonteoh

1
Saya tidak yakin brew reinstall python@2masih berfungsi karena saya pikir minuman telah menghapus python2.
oliversm

Itu bekerja untuk saya. Terima kasih!!!
Martin Forte

4

Saya pribadi menggunakan dan akan merekomendasikan pyenv untuk mengelola versi Python. Pada awalnya saya tidak yakin bagaimana cara memperbaikinya, dan mencoba menginstal ulang menggunakan brewseperti yang disarankan di sini . Namun, saya kemudian ingat bahwa saya pernah pyenvmenginstal dan jadi saya bisa memperbaiki kesalahan saya dengan.

pyenv install -f 2.7.15

Itu -f pilihan memaksa instalasi versi bahwa bahkan jika sudah ada pada sistem Anda. Anda perlu menggunakan 2.7.16atau versi apa pun yang Anda inginkan untuk digunakan.

Penggunaan python-buildyang pyenvakan menggunakan opensslperpustakaan dari brewjika tersedia.

Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.