坑了我好久,终于安装成功了,
pip install requests就提示错误
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
网上教程很多, 但是几乎无用。
1. 安装依赖包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel
2. 安装openssl选择openssl 1.1.1g这个后面字母要是g的版本, 其他字母版本无用。
cd /usr/local/src
wget https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_1_1_1g.tar.gz
tar -zxvf openssl-OpenSSL_1_1_1g.tar.gz
cd openssl-OpenSSL_1_1_1g/
./config --prefix=/usr/local/openssl
make && make test && make install
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib/
ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib/
openssl version
sudo vim /etc/ld.so.conf #打开文件,把/usr/local/openssl/lib加的文件最后:
sudo ldconfig -v #设置生效
3.
wget https://www.python.org/ftp/python/3.10.6/Python-3.10.6.tgz
tar -zxvf Python-3.10.6.tgz
cd Python-3.10.6/
./configure --prefix=/usr/local/python3.10 --with-openssl=/usr/local/openssl_1.1
随后修改代码包中的Modules/Setup文件
4. 然后在安装python3
make
make install
ln -s /usr/local/python3/bin/python3.10 /usr/bin/python
ln -s /usr/local/python3/bin/pip3.10 /usr/bin/pip
python -V
终于是成功了。