
ローカルな環境に、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件)
- 最新から表示
- 回答順に表示
No.1
- 回答日時:
ERROR:root:code for hash md5 was not found.
とあるのでここが問題かと。他のimportは試してみまして大丈夫だったんですよね?
pythonのほうは、import md5も失敗しませんか?
もしそうだとするpythonインストール時にopensslのライブラリへの参照が上手く言ってない可能性が考えられます。
回答有り難う御座います。
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']
>>>
--------------------------------
当面の問題は、これで回避出来たので、
真の原因は不明のままですが、これで良しとし、
これ以上原因の究明はしない事にします。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
実行時エラー 3020の対策
-
Application.ScreenUpdating = ...
-
FindFirst を複数条件で検索
-
[python] 文字列を変数名として...
-
「*:*」って何を意味するのでし...
-
<SELECT>タグの折り返し
-
optionのselectedは更新時は効...
-
Perlで、経過をLoading画面みた...
-
シェルスクリプトで、空白(ス...
-
Pythonでコンソールをクリアす...
-
JSONで文字列が長い時
-
UWSCのSELECT文の記述方法
-
セレクトメニューで2つの項目...
-
VB6で、長い時間かかる処理...
-
日齢計算プログラム
-
複数列を持ったリストボックス...
-
【至急!!!】python言語で本を見...
-
初回起動のみ判別したい
-
パソコン → パャRン
-
pythonの この問題が分かりませ...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
Application.ScreenUpdating = ...
-
実行時エラー 3020の対策
-
[python] 文字列を変数名として...
-
FindFirst を複数条件で検索
-
VBAでPDFのコピーとリネームを...
-
vbaでxmlからNodeListでデータ...
-
ACCESS テキストボックスを隙...
-
MSXMLでの属性の存在確認法
-
構造体の各データの表示につい...
-
「*:*」って何を意味するのでし...
-
ifについて
-
JavaScriptのことで
-
Did you name your dog Koro? ...
-
VB6のLSETをVB2005で実現するに...
-
コンボボックスのtag情報の取得...
-
スキン式掲示板のしくみ
-
画面の途中に飛ぶリンクの方法は?
-
Pythonのプログラミング(Tkinter)
-
C++ コマンドプロンプトでの入...
-
GAEでエンティティからキーやID...
おすすめ情報