我不知道为什么,但当我安装时hashlib
,它给出了一个错误。我已经尝试了很多可能的解决方案,如果能得到任何帮助,我将不胜感激。
$ pip install --user hashlib
Collecting hashlib
Using cached https://files.pythonhosted.org/packages/74/bb/9003d081345e9f0451884146e9ea2cff6e4cc4deac9ffd4a9ee98b318a49/hashlib-20081119.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/tania/anaconda3/lib/python3.6/site-packages/setuptools/__init__.py", line 12, in <module>
import setuptools.version
File "/home/tania/anaconda3/lib/python3.6/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/home/tania/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 36, in <module>
import email.parser
File "/home/tania/anaconda3/lib/python3.6/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/home/tania/anaconda3/lib/python3.6/email/feedparser.py", line 27, in <module>
from email._policybase import compat32
File "/home/tania/anaconda3/lib/python3.6/email/_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
File "/home/tania/anaconda3/lib/python3.6/email/utils.py", line 28, in <module>
import random
File "/home/tania/anaconda3/lib/python3.6/random.py", line 46, in <module>
from hashlib import sha512 as _sha512
File "/tmp/pip-install-vm0l089t/hashlib/hashlib.py", line 80
raise ValueError, "unsupported hash type"
^
SyntaxError: invalid syntax
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-vm0l089t/hashlib/
答案1
无法手动安装 hashlib
$ pip install--用户 hashlib
注1:pip
通常是python2命令。
注2:默认情况下存在当代的“hashlib”:
$ locate hashlib.py
/snap/core/4486/usr/lib/python3.5/hashlib.py
/snap/core/4571/usr/lib/python3.5/hashlib.py
/snap/pulsemixer/23/usr/lib/python3.5/hashlib.py
/snap/pulsemixer/8/usr/lib/python3.5/hashlib.py
/snap/software-boutique/31/usr/lib/python3.5/hashlib.py
/snap/ubuntu-mate-welcome/169/usr/lib/python3.5/hashlib.py
/usr/lib/python2.7/hashlib.py
/usr/lib/python2.7/hashlib.pyc
/usr/lib/python3.6/hashlib.py
Hashlib-2008:顾名思义→2008年:太旧的文件经常会失败gcc-7
。
手动:获取hashlib-20081119.zip
https://files.pythonhosted.org/packages/74/bb/9003d081345e9f0451884146e9ea2cff6e4cc4deac9ffd4a9ee98b318a49/hashlib-20081119.zip
使用 Ubuntu 18.04 的示例python2
(使用 python3 失败):
sudo apt install g++ g++-5
unzip hashlib-20081119.zip
cd hashlib-20081119/
export CC=gcc-5 && python setup.py build && sudo python setup.py install
.
.
Writing /usr/local/lib/python2.7/dist-packages/hashlib-20081119.egg-info