昨天我在我的服务器上(ubuntu 14.04)安装了Python 3.6.3版本,现在我不能运行Python 2.7版本(无论是在虚拟环境中还是在主环境中)。
我在谷歌上寻找了解决方法,但没有成功。
我试着按照别人的建议重新安装了openssl。
有人能帮帮我吗?我快要疯了。
--->每当我尝试执行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*
pip install hashlib
安装 Python2.7 吗?并且你的 Python2.7 目录下是否有pip.exe
文件? - IMCoinsimport hashlib
,然后输入dir(hashlib)
。如果一切正常,则输入hashlib._hashlib
。现在作为测试:hashlib.sha1("").hexdigest()
,然后输入hashlib.sha384("").hexdigest()
。其中至少一个会失败。更进一步:import ssl
,ssl.OPENSSL_VERSION
,以查看正在自动使用的 OpenSSL 版本。之后再对 _hashlib 动态模块执行ldd
(在我的系统上是:*/usr/lib/python2.7/lib-dynload/_hashlib.x86_64-linux-gnu.so*)。 - CristiFati