
ローカルな環境に、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で質問しましょう!
似たような質問が見つかりました
- Ruby 教えてください 2 2023/01/04 17:50
- その他(プログラミング・Web制作) python 2 2022/12/23 09:06
- オープンソース stable diffusionのインストールがうまくいきません。 1 2023/06/20 13:09
- Ruby パイソンエラーについて 1 2022/12/24 14:07
- その他(プログラミング・Web制作) python flask から fastapiへの移行時のエラー対処 1 2023/02/05 12:26
- その他(プログラミング・Web制作) Pythonで会員サイトの自動ログイン ID Nameがない 1 2022/12/16 02:09
- サーバー WindowsでApache が起動しない 1 2022/11/29 12:21
- その他(プログラミング・Web制作) pythonのこのエラーがわかりません 3 2022/11/16 14:54
- Ruby pythonエラー 4 2022/11/11 19:12
- その他(プログラミング・Web制作) pythonをjupiter notebookからmecabで頻出の高い単語の抽出について(Runt 1 2022/12/17 18:08
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
JavaScriptのことで
-
コンパイラの違いについて
-
Application.ScreenUpdating = ...
-
「*:*」って何を意味するのでし...
-
メタキーワードの複数記載に関して
-
特定文字が含まれるシート名を...
-
[RFC821]<mailbox>の<domain>に...
-
GAEでエンティティからキーやID...
-
C++ コマンドプロンプトでの入...
-
構造体の各データの表示につい...
-
CTR-Dでプログラムを終了
-
保存名変更で使用することは可...
-
続・開始時間、終了時間のCGI設定
-
画像ファイルが崩れる
-
HTMLのアクセスキーはselectに...
-
フォームの太字を置き換える
-
年・月・日の3つのselectメニュ...
-
リストボックス内の文字について
-
CSVファイルに出力
-
Spamassassinでsendmailが通ら...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
Application.ScreenUpdating = ...
-
実行時エラー 3020の対策
-
FindFirst を複数条件で検索
-
ACCESS テキストボックスを隙...
-
[python] 文字列を変数名として...
-
vbaでxmlからNodeListでデータ...
-
VBAでPDFのコピーとリネームを...
-
コンボボックスのtag情報の取得...
-
【メモリ不足で落ちる(python)】
-
構造体の各データの表示につい...
-
構造体の変数の値を、動的に取...
-
phpでボタンを押したときに変数...
-
VBAで特殊文字を出力したい
-
C言語でテキストを抽出
-
PHP+SQLiteでmax(id)が使えない?
-
「*:*」って何を意味するのでし...
-
C++ コマンドプロンプトでの入...
-
2つのpythonがあって、一方で...
-
VBAでシート名の定義を変更した...
-
GUI操作のCUI化
おすすめ情報