Python 错误:root:未找到哈希 md5 的代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41798118/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ERROR:root:code for hash md5 was not found
提问by JB_User
I'm on a Linux machine without root access. I built my own local copy of openssl and python (2.7.13). When I try to import hashlib in python, I get these error messages:
我在一台没有 root 访问权限的 Linux 机器上。我构建了自己的 openssl 和 python (2.7.13) 本地副本。当我尝试在 python 中导入 hashlib 时,我收到以下错误消息:
> python
Python 2.7.13 (default, Jan 22 2017, 19:23:53)
[GCC Intel(R) C++ gcc 4.8 mode] on linux2
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 "/home/user_jp/srcMisc/Python-2.7.13/INSTALL/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/home/user_jp/srcMisc/Python-2.7.13/INSTALL/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 "/home/user_jp/srcMisc/Python-2.7.13/INSTALL/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/home/user_jp/srcMisc/Python-2.7.13/INSTALL/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 "/home/user_jp/srcMisc/Python-2.7.13/INSTALL/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/home/user_jp/srcMisc/Python-2.7.13/INSTALL/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 "/home/user_jp/srcMisc/Python-2.7.13/INSTALL/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/home/user_jp/srcMisc/Python-2.7.13/INSTALL/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 "/home/user_jp/srcMisc/Python-2.7.13/INSTALL/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/home/user_jp/srcMisc/Python-2.7.13/INSTALL/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 "/home/user_jp/srcMisc/Python-2.7.13/INSTALL/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/home/user_jp/srcMisc/Python-2.7.13/INSTALL/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512
UPDATE: I just realized that the python build failed to build the hashlib module:
更新:我刚刚意识到 python 构建未能构建 hashlib 模块:
building '_hashlib' extension
gcc -pthread -fPIC -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/p/home/user_jp/srcMisc/Python-2.7.13/INSTALL/include -I. -IInclude -I./Include -I/usr/lo
cal/include -I/p/home/user_jp/srcMisc/Python-2.7.13/Include -I/p/home/user_jp/srcMisc/Python-2.7.13 -c /p/home/user_jp/srcMisc/Python-2.7.13/Modules/_hashopenssl.c -o build/temp.linux-x8
6_64-2.7/p/home/user_jp/srcMisc/Python-2.7.13/Modules/_hashopenssl.o
In file included from /usr/include/openssl/asn1.h:74:0,
from /usr/include/openssl/objects.h:960,
from /usr/include/openssl/evp.h:98,
from /p/home/user_jp/srcMisc/Python-2.7.13/Modules/_hashopenssl.c:39:
/p/home/apps/gmpapp/gcc_dir/platform/gcc-4.8.4/lib/gcc/x86_64-unknown-linux-gnu/4.8.4/include-fixed/openssl/bn.h:610:1: error: unknown type name 'CRYPTO_THREADID'
CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);
^
How should I fix this? It looks like the problem might be that it's looking for the openssl headers in /usr/include/openssl, but I'm trying to use my own installation of openssl.
我应该如何解决这个问题?看起来问题可能在于它正在 /usr/include/openssl 中寻找 openssl 标头,但我正在尝试使用我自己安装的 openssl。
回答by user1978019
I saw this as one of the first of a host of errors when using YouCompleteMein vim on OSX. This was after migrating from one Mac to another using the Migration Assistant, so I wasn't doing a fresh install. In my case it was because the Anaconda python distribution was messing with Homebrew.
在 OSX 上的 vim 中使用YouCompleteMe 时,我认为这是众多错误中的第一个。这是在使用迁移助手从一台 Mac 迁移到另一台 Mac 之后,所以我没有进行全新安装。就我而言,这是因为 Anaconda python 发行版与 Homebrew 混为一谈。
As brew doctor
warned me, Anaconda can cause problems for Homebrew. So I removed the part of my path that included anaconda
and then ran:
正如brew doctor
我警告的那样,Anaconda 可能会给 Homebrew 带来问题。所以我删除了包含的路径部分,anaconda
然后运行:
brew uninstall macvim
brew install macvim
brew linkapps
Homebrew complained that brew linkapps
is not a good command, but it worked for me all the same, and my vim errors went away.
Homebrew 抱怨这brew linkapps
不是一个好的命令,但它对我来说仍然有效,并且我的 vim 错误消失了。
回答by C0rn3j
I've had a similar issue on Ubuntu 16.04. Turns out I needed the package libssl-dev
.
我在 Ubuntu 16.04 上遇到过类似的问题。原来我需要这个包libssl-dev
。
(ERROR:root:code for hash md5 was not found.)
(错误:root:未找到哈希 md5 的代码。)
回答by JB_User
Figured it out. The python build scripts were looking in /usr/include
for the openssl header files. Since I installed my own local version of openssl, those header files were wrong.
弄清楚了。python 构建脚本正在寻找/usr/include
openssl 头文件。由于我安装了自己的本地版本的 openssl,所以那些头文件是错误的。
So, I set CFLAGS
to -i/location/correct/openssl/header/files
and did a make distclean
and configure, and build and it worked.
所以,我设置CFLAGS
到-i/location/correct/openssl/header/files
,做了make distclean
和配置,且构建和它的工作。