简体   繁体   中英

failed to install hashlib in python3.5 - error code 1

I am trying to install hashlib on my mac. pip doesn't work, and easy_install also does not work. Here is the error:

  Collecting hashlib
    Using cached hashlib-20081119.zip
      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.5/lib/python3.5/site-packages/setuptools/__init__.py", line 12, in <module>
    import setuptools.version
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/setuptools/version.py", line 1, in <module>
    import pkg_resources
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pkg_resources/__init__.py", line 36, in <module>
    import email.parser
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/email/parser.py", line 12, in <module>
    from email.feedparser import FeedParser, BytesFeedParser
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/email/feedparser.py", line 27, in <module>
    from email import message
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/email/message.py", line 16, in <module>
    from email import utils
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/email/utils.py", line 28, in <module>
    import random
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/random.py", line 45, in <module>
    from hashlib import sha512 as _sha512
  File "/private/var/folders/nw/flrm4y0d499fk5xr2ppxk4sr0000gn/T/pip-build-lv720o4k/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/nw/flrm4y0d499fk5xr2ppxk4sr0000gn/T/pip-build-lv720o4k/hashlib/ 

Any further suggestions would be great. Thanks in advance!

I know this question is very old, but I stumbled upon it on Google because I had the same problem just now. In my case, I was working with an AWS Elastic Beanstalk, and my environment got that exact same cryptic error message about a syntax error inside hashlib.

For AWS, the trick is NOT including all your imports in the requirements.txt file, but only things you would normally have to pip install. That includes modules like hashlib, string, and random.

So for others who stumble upon this question: there is no need to install hashlib, just import it and you're ready to go!

sudo apt-get install libffi-dev g++ libssl-dev

via https://github.com/bigchaindb/bigchaindb/issues/24#issuecomment-183370814

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM