错误:root:找不到哈希md5的代码

时间:2017-01-23 01:37:42

标签: python

我在没有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

更新:我刚刚意识到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 *);
 ^

我该如何解决这个问题?看起来问题可能是它在/ usr / include / openssl中寻找openssl头文件,但我正在尝试使用自己的openssl安装。

3 个答案:

答案 0 :(得分:0)

想出来。 python构建脚本在/usr/include中查找openssl头文件。由于我安装了自己的本地版本的openssl,这些头文件是错误的。

因此,我将CFLAGS设置为-i/location/correct/openssl/header/files并执行make distclean并配置,构建并运行。

答案 1 :(得分:0)

我在OSX上的vim中使用YouCompleteMe时发现这是一系列错误中的第一个。这是在使用迁移助手从一台Mac迁移到另一台Mac之后,所以我没有进行全新安装。在我的情况下,这是因为Anaconda python发行版混乱了Homebrew。

正如brew doctor警告我的那样,Anaconda会给Homebrew造成问题。所以我删除了包含anaconda的路径部分,然后运行:

brew uninstall macvim
brew install macvim
brew linkapps

Homebrew抱怨brew linkapps不是一个好的命令,但它对我来说都是一样的,我的vim错误也消失了。

答案 2 :(得分:0)

我在Ubuntu 16.04上遇到了类似的问题。结果我需要包libssl-dev

(错误:root:找不到散列md5的代码。)