我有一个依赖于 hashlib 的脚本,但是当我尝试 sudo pip install hashlib 时,我得到了这个:
$ sudo pip install hashlib
Collecting hashlib
Downloading hashlib-20081119.zip (42kB)
100% |████████████████████████████████| 51kB 610kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/setuptools/__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "/usr/lib/python2.7/dist-packages/setuptools/extension.py", line 8, in <module>
from .dist import _get_unpatched
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 16, in <module>
from setuptools.depends import Require
File "/usr/lib/python2.7/dist-packages/setuptools/depends.py", line 6, in <module>
from setuptools import compat
File "/usr/lib/python2.7/dist-packages/setuptools/compat.py", line 17, in <module>
import httplib
File "/usr/lib/python2.7/httplib.py", line 80, in <module>
import mimetools
File "/usr/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/usr/lib/python2.7/tempfile.py", line 35, in <module>
from random import Random as _Random
File "/usr/lib/python2.7/random.py", line 49, in <module>
import hashlib as _hashlib
File "hashlib.py", line 115, in <module>
f()
TypeError: 'frozenset' object is not callable
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-BbiB5F/hashlib/
我该如何修复此问题?
答案1
有同样的错误。尝试easy_install hashlib
答案2
我在最新的 Ubuntu 16 桌面上遇到了同样的问题。
快速而简单的解决方法是删除/usr/lib/python2.7/lib-dynload/_hashlib.x86_64-linux-gnu.so file
。
答案3
删除后/usr/lib/python2.7/lib-dynload/_hashlib.x86_64-linux-gnu.so
,我需要再运行一步
sudo pip install python-dev
之后,运行sudo pip install hashlib
成功。