Unsupported hash type error while installing hashlib using pip3

Lars S picture Lars S · Sep 9, 2017 · Viewed 7.1k times · Source

I am trying to install the hashlib library for Python 3.6.0. Using pip3:

pip3 install hashlib

I get:

Collecting hashlib
  Downloading hashlib-20081119.zip (42kB)
  100% |████████████████████████████████| 51kB 1.6MB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/__init__.py", line 10, in <module>
        from setuptools.extern.six.moves import filter, filterfalse, map
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/extern/__init__.py", line 1, in <module>
        from pkg_resources.extern import VendorImporter
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 36, in <module>
        import email.parser
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/parser.py", line 12, in <module>
        from email.feedparser import FeedParser, BytesFeedParser
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/feedparser.py", line 27, in <module>
        from email._policybase import compat32
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/_policybase.py", line 9, in <module>
        from email.utils import _has_surrogates
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/utils.py", line 28, in <module>
        import random
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/random.py", line 46, in <module>
        from hashlib import sha512 as _sha512
      File "/private/var/folders/3m/q2pmrqbd2l9154yp_9ww5rjm0000gn/T/pip-build-1upkmzey/hashlib/hashlib.py", line 80
        raise ValueError, "unsupported hash type"
                        ^
    SyntaxError: invalid syntax

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/3m/q2pmrqbd2l9154yp_9ww5rjm0000gn/T/pip-build-1upkmzey/hashlib/

Any idea on how to fix this? I am currently on macOS Sierra 10.12.6, using pip3 9.0.1 and python 3.6.

Answer

Lars S picture Lars S · Nov 12, 2018

As pointed out by Bijoy, there is no need to download the hashlib module as it is installed by default.

Simply use import hashlib to use it.