'frozenset' object is not callable
Asked Answered
B

5

19

When I attempt to import hashlib in any context, it throws this error:

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

Any idea how I can resolve this? I'm generating this error simply by opening up Terminal, running python and then typing import hashlib.

Badlands answered 4/12, 2015 at 7:53 Comment(6)
Try from a different working directory.Hatfield
I kind of fixed it, in that I removed a bunch of hashlib.py files. However, now it's not installed and trying to install it with pip or easy_install gives the same frozenset error.Badlands
hashlib should be in the standard library. No need to install anything.Hatfield
It looks like you have a corrupted custom installation of Python. OS X 10.11 has a built-in Python 2.7 in /usr/bin/python, and hashlib in /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py.Forgotten
I tried importing it on a brand new Mac, and got this error. What do you recommend doing?Badlands
I have the same erro when installing "hmac" through pip.Occasionally
S
13

I had the same problem yesterday, Hashlib wasn't installed and trying to install it using pip would give that error. I fixed it by installing it using easy_install instead.

Also I had to install Scipy and Microsoft Visual C++ Compiler for Python 2.7 on Windows, they were required for Hashlib

Soble answered 1/4, 2016 at 17:19 Comment(0)
C
3

I had this problem installing hashlib on OSX (El Capitan), after a failed pip install of hashlib and re-attemp using easy_install. After the event, I had errors just calling pip, let alone loading hashlib.

Root cause was pip adding a bad egg directory path to my sys.path and 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']

To fix, you can delete the file referenced directly, in my case:

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

I tried deleting just the directory reference, but after exploring here to identify the site.py and site_packages.py file belonging to my Current python version, which defines your paths, then looked at where site_packages.py was loading its paths from, it appears that the specific reference is added directly by pip? so the only workaround I could think of was to potentially hard code a line at the end of site.py to remove the reference, which I've seen on other threads.

Connelley answered 18/5, 2016 at 14:1 Comment(0)
A
2

The best solution I found is this: https://mcmap.net/q/190623/-python-2-7-on-os-x-typeerror-39-frozenset-39-object-is-not-callable-on-each-command

It allows to install hashlib with pip with no problems.

Annulation answered 26/10, 2016 at 10:29 Comment(0)
K
1

I had this same message on Fedora 29.

I ended up installing with easy_install hashlib, however, I had to do the following steps first:

dnf install python2-devel
Kamp answered 5/4, 2019 at 12:28 Comment(0)
P
0

On Mac OS I fixed it by installing it easy_install hashlib instead pip install hashlib

Pomcroy answered 26/3, 2021 at 10:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.