繁体   English   中英

'frozenset' 对象不可调用

[英]'frozenset' object is not callable

当我尝试在任何上下文中导入hashlib时,它会引发此错误:

File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.11-intel/egg/hashlib.py", line 115, in <module>
    """
TypeError: 'frozenset' object is not callable

知道我该如何解决这个问题吗? 我只是通过打开终端,运行python然后输入import hashlib来生成这个错误。

我昨天遇到了同样的问题,未安装 Hashlib,尝试使用 pip 安装它会出现该错误。 我通过使用 easy_install 安装它来修复它。

此外,我必须在 Windows 上 为 Python 2.7安装 Scipy 和Microsoft Visual C++ 编译器,Hashlib 需要它们

我在 OSX (El Capitan) 上安装 hashlib 时遇到了这个问题,在 hashlib 的 pip 安装失败并使用 easy_install 重新尝试之后。 活动结束后,我在调用 pip 时出错,更不用说加载 hashlib 了。

根本原因是 pip 添加了一个坏蛋目录路径到我的 sys.path 和 PYTHONHOME:

>>> import sys
>>> print sys.path
['', '/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg', '/Library/Python/2.7/site-packages/hashlib-20081119-py2.7-macosx-10.11-intel.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages']

要修复,您可以直接删除引用的文件,在我的情况下:

rm /Library/Python/2.7/site-packages/hashlib-20081119-py2.7-macosx-10.11-intel.egg

我尝试只删除目录引用,但在探索此处确定属于我当前 python 版本的 site.py 和 site_packages.py 文件后,该文件定义了您的路径,然后查看了 site_packages.py 从何处加载其路径,它出现pip 直接添加特定引用? 所以我能想到的唯一解决方法是在 site.py 的末尾对一行进行硬编码以删除引用,我在其他线程上看到过。

我找到的最佳解决方案是: https : //stackoverflow.com/a/40259767/3689574

它允许使用 pip 安装 hashlib 没有问题。

我在 Fedora 29 上收到了同样的消息。

我最终使用easy_install hashlib安装,但是,我必须先执行以下步骤:

dnf install python2-devel

在 Mac OS 上,我通过安装easy_install hashlib来修复它,而不是pip install hashlib

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM