python hashlib fails to install pip

21,329

Solution 1

Had the same error. Try easy_install hashlib

Solution 2

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.

Solution 3

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.

Share:
21,329

Related videos on Youtube

j0h
Author by

j0h

been using Linux since 2005. Ubuntu since whenever edgy eft was new. Lucid Lynx Ubuntu was the best Ubuntu I have ever used.

Updated on September 18, 2022

Comments

  • j0h
    j0h almost 2 years

    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?

  • temple
    temple over 7 years
    save my time and save my life!
  • Ole Henrik Skogstrøm
    Ole Henrik Skogstrøm about 6 years
    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?
  • Sim
    Sim about 6 years
    I am using Ubuntu 14.04 and this answer did not solve the issue whereas the other did (remove file and reinstall hashlib)
  • Sergey Vlasov
    Sergey Vlasov about 4 years
    It failed for me on RPi 3+ with python 3.7.3