ローカルな環境に、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を探す
おすすめ情報
- ・漫画をレンタルでお得に読める!
- ・人生のプチ美学を教えてください!!
- ・10秒目をつむったら…
- ・あなたの習慣について教えてください!!
- ・牛、豚、鶏、どれか一つ食べられなくなるとしたら?
- ・【大喜利】【投稿~9/18】 おとぎ話『桃太郎』の知られざるエピソード
- ・街中で見かけて「グッときた人」の思い出
- ・「一気に最後まで読んだ」本、教えて下さい!
- ・幼稚園時代「何組」でしたか?
- ・激凹みから立ち直る方法
- ・1つだけ過去を変えられるとしたら?
- ・【あるあるbot連動企画】あるあるbotに投稿したけど採用されなかったあるある募集
- ・【あるあるbot連動企画】フォロワー20万人のアカウントであなたのあるあるを披露してみませんか?
- ・映画のエンドロール観る派?観ない派?
- ・海外旅行から帰ってきたら、まず何を食べる?
- ・誕生日にもらった意外なもの
- ・天使と悪魔選手権
- ・ちょっと先の未来クイズ第2問
- ・【大喜利】【投稿~9/7】 ロボットの住む世界で流行ってる罰ゲームとは?
- ・推しミネラルウォーターはありますか?
- ・都道府県穴埋めゲーム
- ・この人頭いいなと思ったエピソード
- ・準・究極の選択
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
Application.ScreenUpdating = ...
-
VBAでPDFのコピーとリネームを...
-
FindFirst を複数条件で検索
-
実行時エラー 3020の対策
-
ACCESS テキストボックスを隙...
-
コンボボックスのtag情報の取得...
-
Perl テキスト 重複 個数
-
メ-ルにno problem@の前にname...
-
シェル変数でYYYYMMDDをいれた...
-
エクセルVBA シート名の部分一...
-
[python] 文字列を変数名として...
-
文字列配列をメンバにもつ構造...
-
構造体の各データの表示につい...
-
JSONで文字列が長い時
-
16進の10進変換について
-
formで特定のinputを送信しない...
-
関数「exists」と「defined」の...
-
テーブル内でドロップダウンメ...
-
VB6で、長い時間かかる処理...
-
sendmailで複数アドレスに送信...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
Application.ScreenUpdating = ...
-
実行時エラー 3020の対策
-
FindFirst を複数条件で検索
-
VBAでPDFのコピーとリネームを...
-
ACCESS テキストボックスを隙...
-
[python] 文字列を変数名として...
-
2つのpythonがあって、一方で...
-
「*:*」って何を意味するのでし...
-
構造体の各データの表示につい...
-
コンボボックスのtag情報の取得...
-
phpでボタンを押したときに変数...
-
UWSC:ポップアップウインドウ...
-
C++ コマンドプロンプトでの入...
-
vbaでxmlからNodeListでデータ...
-
MSXMLでの属性の存在確認法
-
vscode 文字化け
-
この英語はどういう意味ですか?
-
VBA他のブックから値のみ貼付す...
-
[ASP.net Ajax]フレーム分割し...
-
講義でわからないのですが以下...
おすすめ情報