Python 2.7 不再工作:无法导入名称 md5
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47884422/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python 2.7 not working anymore: cannot import name md5
提问by JulienCoo
I installed python 3.6.3 on my server yesterday (ubuntu 14.04), and now I cannot run python 2.7 (in the virtual envs and on the 'main env').
我昨天在我的服务器上安装了 python 3.6.3(ubuntu 14.04),现在我无法运行 python 2.7(在虚拟环境和“主环境”上)。
I've been looking around google for this, without success.
我一直在寻找谷歌,但没有成功。
I tried to re-intall openssl as I red.
当我变红时,我尝试重新安装 openssl。
Can anyone help me ? I'm going mad.
谁能帮我 ?我要疯了。
---> Here is the message whenever i tried to execute a python script (or pip):
---> 这是每当我尝试执行 python 脚本(或 pip)时的消息:
*ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/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/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/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/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/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/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructoremphasized text
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/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/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/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/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 "/var/www/QuantEngine/prod/QuantScripts/QuantEngineCli.py", line 11, in <module>
from services import DataStructureManager, DatabaseFsHelper, Orchestra, BacktestManager
File "/var/www/QuantEngine/prod/QuantScripts/services/__init__.py", line 8, in <module>
from BuySellManager import BuySellManager
File "/var/www/QuantEngine/prod/QuantScripts/services/BuySellManager.py", line 1, in <module>
import requests
File "/var/www/QuantEngine/venv/lib/python2.7/site- packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/var/www/QuantEngine/venv/lib/python2.7/site- packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/var/www/QuantEngine/venv/lib/python2.7/site- packages/urllib3/connectionpool.py", line 29, in <module>
from .connection import (
File "/var/www/QuantEngine/venv/lib/python2.7/site-packages/urllib3/connection.py", line 39, in <module>
from .util.ssl_ import (
File "/var/www/QuantEngine/venv/lib/python2.7/site- packages/urllib3/util/__init__.py", line 6, in <module>
from .ssl_ import (
File "/var/www/QuantEngine/venv/lib/python2.7/site- packages/urllib3/util/ssl_.py", line 7, in <module>
from hashlib import md5, sha1, sha256
ImportError: cannot import name md5*
回答by recluse
I had the same problem on macOS.
我在 macOS 上遇到了同样的问题。
brew reinstall python@2
solved this problem.
brew reinstall python@2
解决了这个问题。
Maybe you could try to reinstall python.
也许您可以尝试重新安装python。
回答by Vasily Bronsky
In this postmight be a solution:
在这篇文章中可能是一个解决方案:
The python2.7 package is dependent to the libssl1_0_0 package (openssl_1.0 runtime librairies).
python2.7 包依赖于 libssl1_0_0 包(openssl_1.0 运行时库)。
So you need to install it, and add the /usr/local/ssl/lib directory in $LD_LIBRARY_PATH environnent variable.
所以你需要安装它,并在 $LD_LIBRARY_PATH 环境变量中添加 /usr/local/ssl/lib 目录。