6

I have a script that depends on hashlib, but when I try sudo pip install hashlib I get this:

$ 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/

What can I do to fix this?

  • 1
    I noticed I already had hashlib installed by default for Python 2.7.11 on Ubuntu 16.04, so can you check if that is the case for you? If this is indeed the case, there is no need to install it via pip. – edwinksl Jun 29 '16 at 15:38
7

Had the same error. Try easy_install hashlib

  • save my time and save my life! – temple Oct 17 '16 at 5:37
  • Ironically this gives me the error: "ImportError: No module named hashlib"... Any philosophers or ubuntu wranglers out there that want to try explaining that one? – Ole Henrik Skogstrøm Apr 18 '18 at 10:23
  • I am using Ubuntu 14.04 and this answer did not solve the issue whereas the other did (remove file and reinstall hashlib) – Sim May 24 '18 at 8:43
6

I encountered the same problem on the latest Ubuntu 16 Desktop.
The quick and dirty fix is to remove the /usr/lib/python2.7/lib-dynload/_hashlib.x86_64-linux-gnu.so file.

1

After remove /usr/lib/python2.7/lib-dynload/_hashlib.x86_64-linux-gnu.so, I need run one more step

sudo pip install python-dev

After that, run sudo pip install hashlib successfully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.