11

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.

3
  • 6
    hashlib module is installed by default. No need to Install it, as you can see it has python 2.* coding syntax. Commented Sep 9, 2017 at 11:26
  • @Bijoy I encounter the same problem. hashlib is included by default, I can import hashlib. But I can’t do from hashlib import blake2b. I know my code is working in two other environements but I have this error just now when trying to run it on a new fresh environnement. So far I have upgrade pip with pip3 install --upgrade pip, and then, trying to install hashlib fails with the same error as OP. I remember I have to install the hashlib module from pip, because the version which comes in my distro hasn’t this algorithm… Or should I use another ? 'BLAKE2b512', 'BLAKE2s256' ? Commented Nov 11, 2018 at 3:13
  • @Bijoy : And my pip installation seems to be fine as I can install some other libs, like paramiko. Commented Nov 11, 2018 at 3:20

1 Answer 1

13

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.