アプリ版:「スタンプのみでお礼する」機能のリリースについて

ローカルな環境に、python2 と python の2つの python が入っています。
下記に示すように、python2 では、import hashlib に成功するのですが、
python では、import hashlib に失敗してしまいます。
python の方でも、正しく import hashlib に成功するようにしたいのですが、
どこをどう修正すれば良いか、よく分からないです。

importの設定で、モジュールがあるのは何処のディレクトリなのか、
そのディレクトリを何処にどう書くのか、がよく分からないです。

python の方でも、正しく import hashlib に成功するようにする手順を
お教えください。

--------------------------------
↓ import hashlib に成功する phyton2
--------------------------------
bash-3.2$ which python2
/Users/inamoto/.local/bin/python2
bash-3.2$ python2
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> dir(hashlib)
['__all__', '__builtins__', '__doc__', '__file__', '__get_builtin_constructor', '__name__', '__package__', '_hashlib', '_trans_36', '_trans_5C', 'algorithms', 'algorithms_available', 'algorithms_guaranteed', 'binascii', 'md5', 'new', 'pbkdf2_hmac', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'struct']
--------------------------------
↓ import hashlib に失敗する phyton
--------------------------------
bash-3.2$ which python
/Users/inamoto/gtk/inst/bin/python
bash-3.2$ python
Python 2.7.11 (default, Jun 12 2016, 18:51:52)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
File "/Users/inamoto/gtk/inst/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/Users/inamoto/gtk/inst/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
File "/Users/inamoto/gtk/inst/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/Users/inamoto/gtk/inst/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
File "/Users/inamoto/gtk/inst/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/Users/inamoto/gtk/inst/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
File "/Users/inamoto/gtk/inst/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/Users/inamoto/gtk/inst/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
File "/Users/inamoto/gtk/inst/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/Users/inamoto/gtk/inst/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
File "/Users/inamoto/gtk/inst/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/Users/inamoto/gtk/inst/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512
>>>
--------------------------------

以上、宜しくお願い申し上げます。

A 回答 (1件)

ERROR:root:code for hash md5 was not found.


とあるのでここが問題かと。他のimportは試してみまして大丈夫だったんですよね?
pythonのほうは、import md5も失敗しませんか?
もしそうだとするpythonインストール時にopensslのライブラリへの参照が上手く言ってない可能性が考えられます。
    • good
    • 0
この回答へのお礼

回答有り難う御座います。
pythonの方は、import md5 にも失敗します。

試しに、/Users/inamoto/gtk/inst/bin/python を
削除した所、3つ目のpythonがあり、これは、
以下のように、import hashlib に成功します。
--------------------------------
bash-3.2$ which python
/usr/bin/python
bash-3.2$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> dir(hashlib)
['__all__', '__builtins__', '__doc__', '__file__', '__get_builtin_constructor', '__name__', '__package__', '_hashlib', '_trans_36', '_trans_5C', 'algorithms', 'algorithms_available', 'algorithms_guaranteed', 'binascii', 'md5', 'new', 'pbkdf2_hmac', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'struct']
>>>
--------------------------------
当面の問題は、これで回避出来たので、
真の原因は不明のままですが、これで良しとし、
これ以上原因の究明はしない事にします。

お礼日時:2016/06/16 10:02

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!