[PYTHON] What to do when raise ValueError, "unsupported hash type"

Event: Attempt to install hmac failed

--Environment: Cloud9

$ pip install hmac
Defaulting to user installation because normal site-packages is not writeable
Collecting hmac
  Downloading hmac-20101005.tar.gz (4.5 kB)
Requirement already satisfied: setuptools in /usr/lib/python3.6/dist-packages (from hmac) (36.2.7)
Collecting hashlib
  Downloading hashlib-20081119.zip (42 kB)
     |████████████████████████████████| 42 kB 1.1 MB/s 
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.6 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-5jes0rhx/hashlib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-5jes0rhx/hashlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-uvx1s968
         cwd: /tmp/pip-install-5jes0rhx/hashlib/
    Complete output (22 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.6/dist-packages/setuptools/__init__.py", line 10, in <module>
        from setuptools.extern.six.moves import filter, map
      File "/usr/lib/python3.6/dist-packages/setuptools/extern/__init__.py", line 1, in <module>
        from pkg_resources.extern import VendorImporter
      File "/usr/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 36, in <module>
        import email.parser
      File "/usr/lib64/python3.6/email/parser.py", line 12, in <module>
        from email.feedparser import FeedParser, BytesFeedParser
      File "/usr/lib64/python3.6/email/feedparser.py", line 27, in <module>
        from email._policybase import compat32
      File "/usr/lib64/python3.6/email/_policybase.py", line 9, in <module>
        from email.utils import _has_surrogates
      File "/usr/lib64/python3.6/email/utils.py", line 28, in <module>
        import random
      File "/usr/lib64/python3.6/random.py", line 46, in <module>
        from hashlib import sha512 as _sha512
      File "/tmp/pip-install-5jes0rhx/hashlib/hashlib.py", line 80
        raise ValueError, "unsupported hash type"
                        ^
    SyntaxError: invalid syntax
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Cause: You don't need to install it in the first place

It seems that hmac and hashlib are available even if you don't install them ... Requirement already satisfied: setuptools in /usr/lib/python3.6/dist-packages (from hmac) (36.2.7) It is written. Once you know the result, you don't understand why you tried to install it for the time being.

Reference: python --Unsupported hash type error while installing hashlib using pip3 --Stack Overflow

I've been extremely confused with HMAC and Cloud9 for the first time, and even upgraded Python ...

Action: Just use without installing

OK if you write and use import hmac, hashlib

Recommended Posts

What to do when raise ValueError, "unsupported hash type"
What to do when Ubuntu crashes
TypeError: unsupported operand type (s) for-: What to do when'datetime.time'and'datetime.time'
What to do when the value type is ambiguous in Python?
What to do when PermissionError of tempfile.mkstemp occurs
What to do when xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record;
What to do when "TypeError: data type not understood" appears in python's numpy.zeros
[Go 1.13] What to do when unexpected directory layout: appears
[openpyxl] What to do when IllegalCharacterError appears in pandas.DataFrame.to_excel
curl: (60) What to do when Issuer certificate is invalid.
What to do when gdal_merge creates a huge file
What to do when "cannot import name xxx" [Python]
What to do when you can't bind CaboCha to Python
[Python] Type Error:'WebElement' object is not iterable What to do when an error occurs
What to do when python3 type venv does not work well on Raspberry Pi
What to do when "Type Error: must be _socket.socket, not socket" appears on GAE
[AWS] What to do when you want to pip with Lambda
What to do when Japanese is not displayed on matplotlib
What to do when PyCharm font is strange or garbled
What to do when a Remove Error occurs when updating conda
What to do when Unalignable boolean Series provided as indexer
What to do when an error occurs with import _ssl
What to do if package installation fails when deploying to heroku
What to do when "SSL: CERTIFICATE_VERIFY_FAILED _ssl.c: 1056" appears in Python
OSError: [Errno 40] What to do when Message too long appears
What to do when "Invalid HTTP_HOST header" appears in Django
ImportError: No module What to do when you are told
[AWS] What to do when the ping command causes a "timeout"
What to do if yum breaks
What to do with Magics install
What to do when a video cannot be read by cv2.VideoCapture
[Beanstalk] What to do when an error occurs with import uuid
What to do when the jupyterlab extension settings are not reflected
What to do with PYTHON release?
What to do if Insecure Platform Warning appears when running Python
What to do when you get "I can't see the site !!!!"
What to do when UnicodeDecodeError occurs during read_csv in pandas (pd.read_table ())
What to do to get tensorflow-gpu to work
What to do when ModuleNotFoundError: No module named'XXX' occurs in Python
What to do when the result downloaded via scrapy is in English
What to do when pyinstaller: error: argument --add-binary: invalid add_data_or_binary value: appears
[Docker] What to do when error Couldn't find the binary git appears
[Python] What to do when an error related to SSL authentication is returned
What to do if an error occurs when importing numpy with VScode
What to do if you get an error when trying to load mnist
What to do if fprintd requires a password when registering your fingerprint
What to do when the warning "The environment is in consistent ..." appears in the Anaconda environment
Notes on what to do when matplotlib scatter () / scatter3d () does not work
What to do if you get an error when installing Dlib (Ubuntu)
After all, what should I use to do type comparisons in Python?
[OSX] [pyenv] What to do when an SSL error occurs in pip
What to do when psycopg2 throws an error when pipenv lock under Pipenv environment
What to do when a warning message is displayed in pip list
What to do after installing Linux (Ubuntu)
Let's summarize what you want to do.
Example of what to do when the sample script does not work (OpenCV-Python)
What to do if CERTIFICATE_VERIFY_FAILED occurs when nltk.download () is done on macOS pyhon
[python] What to do when an error occurs in send_keys of headless chrome
What to do when "TypeError: must be string, not int…" appears when using strptime
What to do when SSL error occurs in pip in Windows10, miniconda, VScode environment
What to do when a warning appears around Python integration in Neovim's CheckHealth