AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1618009
Accepted
Eduardo Lucio
Eduardo Lucio
Asked: 2021-01-16 14:20:01 +0800 CST2021-01-16 14:20:01 +0800 CST 2021-01-16 14:20:01 +0800 CST

python3.2 - 错误:root:未找到哈希 md5 的代码

  • 772

我们有一个遗留应用程序,它需要 Python 3.2 版才能工作。为此,我们编译并安装Python 3.2 版。

我们能够在Ubuntu 20.04.1 LTS上成功编译和安装 3.2 版 Python ,但是我们开始遇到使用Python“hashlib”库的问题,如下面的摘录所示......

root@sinj:/usr/local/src/lbginst# /usr/local/lb/py32/bin/python3.2 -c "import hashlib;m=hashlib.md5();print(m.hexdigest())"
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 141, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
  File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 141, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
  File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 141, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
  File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 141, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
  File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 141, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
  File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 141, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha512
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'md5'

问题:我们如何解决提出的问题?

注意 I:在互联网上查阅了数十个资源后,我们开始怀疑与libssl.so libcrypto.so二进制文件有关的某些内容。
注二:我们如何诊断正在发生的事情的信息也非常受欢迎!

谢谢!=D


更新:另一个症状是在构建过程中出现此消息(make,make install)......

Failed to build these modules:
_hashlib           _ssl   
ubuntu python
  • 2 2 个回答
  • 2845 Views

2 个回答

  • Voted
  1. bk2204
    2021-01-17T14:49:55+08:002021-01-17T14:49:55+08:00

    您的问题是您使用的是 OpenSSL 1.1 和不支持该版本 OpenSSL 的旧版 Python。Python 3.2 于 2011 年发布,OpenSSL 1.1.0 于 2016 年发布。

    由于 OpenSSL 1.0 不再受安全支持,您需要将您正在使用的 Python 版本升级到合适的版本。如果您迫不及待并且计划在接下来的三个月内升级,您还可以使用 Ubuntu 16.04 容器,其中包含 Ubuntu 支持的 OpenSSL 1.0,直到 4 月。但是,Python 3.2 也可能存在未修补的漏洞。

    • 4
  2. Best Answer
    Eduardo Lucio
    2021-01-19T12:23:28+08:002021-01-19T12:23:28+08:00

    出现指出的问题是因为 python 版本 3.2 与 openssl 版本 1.1 不兼容,openssl 版本是apt-getUbuntu 20.04.1 LTS 使用的标准版本 ( )。

    解决方案是编译并安装 ( make, make install) 版本 1.0 的 openssl,并使用变量“CFLAGS”和“LDFLAGS”配置编译过程,使其使用 openssl 版本 1.0。

    # NOTE: Download, compile and install openssl. By Questor
    cd /usr/local/src
    wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2k.tar.gz
    tar -zxvf openssl-1.0.2k.tar.gz
    cd ./openssl-1.0.2k
    ./config -fPIC shared
    make && make install
    cd ..
    rm -rf ./openssl-1.0.2k
    
    # NOTE: Download, compile and install Python 3.2. By Questor
    cd /usr/local/src
    wget https://www.python.org/ftp/python/3.2.2/Python-3.2.2.tgz
    tar -zxvf Python-3.2.2.tgz
    cd ./Python-3.2.2
    
    eval "./configure --with-threads --enable-shared CFLAGS='-I/usr/local/ssl/include/openssl/ -I/usr/local/ssl/include/' LDFLAGS='-L/usr/local/lib/ -L/usr/local/ssl/lib/ -Wl,-rpath,/usr/local/lib/ -Wl,-rpath,/usr/local/ssl/lib/'"
    make && make install
    cd ..
    rm -rf ./Python-3.2.2
    
    # NOTE: Test python3.2 using "_hashlib" and "_ssl" resources. By Questor
    /usr/local/bin/python3.2 -c "import hashlib;m=hashlib.md5();print(m.hexdigest())"
    

    完毕!谢谢!=D

    [参考:https://chowyi.com/%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85Python3%E5%8F%8A %E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3/,https://raspberrypi.stackexchange.com/questions/66782/how-to-install-openssl-1- 0-2-on-raspberry-pi3/66788?newreg=89c76bb5b1f542f88a63268243455e75,https://stackoverflow.com/questions/1904990/what-is-the-difference-between-ld-library-path-and-l-at-链接时间/1905144#1905144,https://stackoverflow.com/questions/22409092/coredump-when-compiling-python-with-a-custom-openssl-version/22409394#22409394,https://stackoverflow.com/问题/5937337/building-python-with-ssl-support-in-non-standard-location/5939170#5939170,https://stackoverflow.com/questions/2537271/compile-openssl-with-the-shared-option/ 23513969#23513969 , https://www.hpc.dtu.dk/?page_id=1180 , https://stackoverflow.com/a/24026737/3223785 , https://www.a2hosting.com/kb/security/ssl/determining-the-openssl-version,https://superuser.com/a/1618761/195840,https://stackoverflow.com/a/46476640/3223785]

    • 1

相关问题

  • 无法打开 Windows 10 和在 Hyper-v 上创建的本地托管的 Ubuntu VM 之间的端口

  • Docker 容器 ssh 错误:ssh_exchange_identification: Connection closed by remote host

  • pip 不会正确更新或安装模块

  • apache2 可以在没有 conf 文件的情况下工作吗?

  • vmwared 共享文件夹不工作

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    v15 为什么通过电缆(同轴电缆)的千兆位/秒 Internet 连接不能像光纤一样提供对称速度? 2020-01-25 08:53:31 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve