You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python 3.4.3可执行文件与libssl路径问题求助

Troubleshooting hashlib Errors with CentOS-built Python 3.4 on Ubuntu 16.04.3

Hey there, let's work through this hashlib issue you're hitting with your legacy Python executable. The core problem here is that the CentOS-built Python 3.4 (from the rh-python34 collection) relies on OpenSSL libraries that don't match Ubuntu 16.04.3's setup. Your path symlinks fixed the Python executable's location, but the underlying library dependencies are still misaligned. Here are actionable steps to resolve this:

1. Verify Ubuntu's OpenSSL Installation

First, make sure you have the correct OpenSSL libraries and development packages installed on Ubuntu:

# Check your current OpenSSL version
openssl version
# Install required packages (Ubuntu 16.04 defaults to OpenSSL 1.0.2g)
sudo apt-get update && sudo apt-get install libssl-dev openssl -y

The CentOS Python expects to find libssl.so and libcrypto.so in /opt/rh/rh-python34/root/usr/lib64/, but Ubuntu stores these libraries in a different location. Let's create symlinks to bridge the gap:

# Find Ubuntu's OpenSSL library paths
find /usr/lib -name libssl.so*
find /usr/lib -name libcrypto.so*
# Create symlinks to Python's expected directory (adjust version numbers if needed)
sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 /opt/rh/rh-python34/root/usr/lib64/libssl.so
sudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /opt/rh/rh-python34/root/usr/lib64/libcrypto.so

3. Check and Adjust Dynamic Library Paths

If the symlinks don't work immediately, verify that Python can find the libraries using ldd:

ldd /opt/rh/rh-python34/root/usr/bin/python3.4

Look for libssl.so and libcrypto.so—if they show not found, temporarily add Ubuntu's library path to your environment and test:

export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
# Test if hashlib works now
python3.4 -c "import hashlib; hashlib.md5(); print('MD5 hash works!')"

If this works, add the LD_LIBRARY_PATH export to your program's startup script to make it permanent.

4. Compile Python 3.4 Natively for Ubuntu (Fallback Solution)

If symlinks don't resolve the issue, compile a Ubuntu-native version of Python 3.4 to match the system's OpenSSL libraries. This replaces the CentOS-built Python while keeping the original path your software expects:

# Install build dependencies
sudo apt-get install build-essential zlib1g-dev libssl-dev libffi-dev -y
# Download Python 3.4.10 (match your original Python's minor version if possible)
wget https://www.python.org/ftp/python/3.4.10/Python-3.4.10.tgz
tar xzf Python-3.4.10.tgz
cd Python-3.4.10
# Configure to install in the original CentOS path, linking to Ubuntu's OpenSSL
./configure --prefix=/opt/rh/rh-python34/root --with-ssl=/usr/lib/x86_64-linux-gnu
# Compile and install
make -j$(nproc)
sudo make install

After installation, test the hashlib functionality again with the same command as above.

5. Validate the Fix

Once you've tried one of the above methods, run this quick test to confirm hashlib is working:

python3.4 -c "
import hashlib
for alg in ['md5', 'sha1', 'sha256', 'sha512']:
    h = hashlib.new(alg)
    h.update(b'test')
    print(f'{alg} hash: {h.hexdigest()}')
"

If all algorithms print without errors, your issue is resolved.

内容的提问来源于stack exchange,提问作者Brian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:03:54