找不到错误:root:哈希md5的代码 - 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安装。

参考方案

在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错误消失了。

Python uuid4,如何限制唯一字符的长度 - python

在Python中,我正在使用uuid4()方法创建唯一的字符集。但是我找不到将其限制为10或8个字符的方法。有什么办法吗?uuid4()ffc69c1b-9d87-4c19-8dac-c09ca857e3fc谢谢。 参考方案 尝试:x = uuid4() str(x)[:8] 输出:"ffc69c1b" Is there a way to…

Python-crontab模块 - python

我正在尝试在Linux OS(CentOS 7)上使用Python-crontab模块我的配置文件如下:{ "ossConfigurationData": { "work1": [ { "cronInterval": "0 0 0 1 1 ?", "attribute&…

Python:检查是否存在维基百科文章 - python

我试图弄清楚如何检查Wikipedia文章是否存在。例如,https://en.wikipedia.org/wiki/Food 存在,但是https://en.wikipedia.org/wiki/Fod 不会,页面只是说:“维基百科没有此名称的文章。”谢谢! 参考方案 >>> import urllib >>> prin…

Python Pandas导出数据 - python

我正在使用python pandas处理一些数据。我已使用以下代码将数据导出到excel文件。writer = pd.ExcelWriter('Data.xlsx'); wrong_data.to_excel(writer,"Names which are wrong", index = False); writer.…

Python GPU资源利用 - python

我有一个Python脚本在某些深度学习模型上运行推理。有什么办法可以找出GPU资源的利用率水平?例如,使用着色器,float16乘法器等。我似乎在网上找不到太多有关这些GPU资源的文档。谢谢! 参考方案 您可以尝试在像Renderdoc这样的GPU分析器中运行pyxthon应用程序。它将分析您的跑步情况。您将能够获得有关已使用资源,已用缓冲区,不同渲染状态上…