Python pip命令返回类型错误

Python pip命令返回类型错误,python,pip,Python,Pip,我需要为我的一个项目安装hashlib,并使用easy\u install hashlib(如所述)来完成。然而,在我安装了这个软件包之后,我根本无法使用pip。每当我使用pip键入命令时(如pip install),我都会收到以下错误消息: Traceback (most recent call last): File "/usr/local/bin/pip", line 5, in <module> from pkg_resources import load_ent

我需要为我的一个项目安装
hashlib
,并使用
easy\u install hashlib
(如所述)来完成。然而,在我安装了这个软件包之后,我根本无法使用pip。每当我使用
pip
键入命令时(如
pip install
),我都会收到以下错误消息:

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 37, in <module>
    import email.parser
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/parser.py", line 12, in <module>
    from email.feedparser import FeedParser
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/feedparser.py", line 27, in <module>
    from email import message
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/message.py", line 16, in <module>
    import email.charset
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/charset.py", line 13, in <module>
    import email.base64mime
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/base64mime.py", line 40, in <module>
    from email.utils import fix_eols
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/utils.py", line 27, in <module>
    import random
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 49, in <module>
    import hashlib as _hashlib
  File "build/bdist.macosx-10.13-intel/egg/hashlib.py", line 115, in <module>
    """
TypeError: 'frozenset' object is not callable
回溯(最近一次呼叫最后一次):
文件“/usr/local/bin/pip”,第5行,在
从打包资源导入加载入口点
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/Python/pkg_resources/__init__.py”,第37行,在
导入email.parser
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/parser.py”,中第12行
从email.feedparser导入feedparser
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/feedparser.py”,第27行,在
从电子邮件导入消息
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/message.py”,第16行,在
导入email.charset
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/charset.py”,第13行,在
导入email.base64mime
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/base64mime.py”,第40行,在
从email.utils导入修复程序
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/utils.py”,第27行,在
随机输入
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py”,第49行,在
将hashlib导入为_hashlib
文件“build/bdist.macosx-10.13-intel/egg/hashlib.py”,第115行,在
"""
TypeError:“frozenset”对象不可调用
现在,当我使用
easy\u install
时,也会发生同样的错误。我也无法卸载pip并重新安装-任何带有
pip
的命令都会导致上述错误。即使执行

pip--version
也会产生同样的错误。我知道这与
hashlib
包有关,但我不确定如何删除它并重新安装,而不会弄乱我的整个Python配置。我的假设是,我安装的
hashlib
版本对于我的Python 2.7来说要么太旧要么太新,而且不会好好利用它

有人知道这个堆栈跟踪的幕后到底发生了什么,以及我如何修复
pip


从我的
lib/python2.7
文件夹中直接进入并删除
hashlib.py
是最好的做法吗?

因此,这并不能解决
hashlib
的问题,但它确实让你再次得到一个工作
pip
:完全重新下载并重新安装Python 2.7。如果有人想出更好、更多的elegant解决方案,我完全支持


然而,至少我可以再次使用
pip

hashlib
自Python 2.5以来一直是一个标准模块。你为什么要安装它?@PM2Ring我是个白痴,认为它是我项目中的新依赖项。已经完成的事情已经完成了。你似乎有一个版本不匹配——你正在运行
/usr/local/bin/python
(可能是自制安装?)针对
/System/Library/Frameworks/Python.framework/Versions/2.7/Lib/python2.7
中的MacOS默认Python库。我强烈怀疑这是一个重复的问题,但不确定到底要搜索什么。