LoginSignup
0
0

More than 3 years have passed since last update.

raise ValueError, "unsupported hash type"となった時の対応方法

Last updated at Posted at 2020-11-20

事象 : hmacをインストールしようとして失敗した

  • 環境 : 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.

原因 : そもそもインストールする必要がないから

インストールしなくてもhmac, hashlibはあるようだ・・・おちついてメッセージを見ると
Requirement already satisfied: setuptools in /usr/lib/python3.6/dist-packages (from hmac) (36.2.7)
と書いてある。
結果がわかると何故とりあえずインストールしようとしたのかがわからない。

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

はじめてのHMACとCloud9で混乱を極めてPythonのバージョンアップなどもしてしまった・・・

対応 : インストールしないでただ使う

import hmac, hashlibを書いて使えばOK

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0