赞
踩
yum -y install gcc
yum -y install zlib-devel
wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz
tar -xvf Python-3.10.0.tgz
cd Python-3.10.0
./configure --prefix=/usr/local/python3
make && make install
ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
python3 -V
cat > hello.py << EOF
#!/usr/local/bin/python3
# -*- coding: utf8 -*-
print("hello world")
EOF
[testuser@localhost ~]$ /usr/local/bin/python3 hello.py
hello world
比如,执行/usr/local/bin/pip3 install PyMySQL会报ssl module的问题如下
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not …
解决步骤:
#下载源码 wget https://codeload.github.com/openssl/openssl/zip/OpenSSL_1_1_1-stable #解压 unzip openssl-OpenSSL_1_1_1-stable.zip #安装,指定安装路径为/usr/local/openssl ./config --prefix=/usr/local/openssl make && make install #备份旧文件并加载新版本配置 mv /usr/bin/openssl /usr/bin/openssl.old mv /usr/lib64/openssl /usr/lib64/openssl.old mv /usr/lib64/libssl.so /usr/lib64/libssl.so.old ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl ln -s /usr/local/openssl/include/openssl /usr/include/openssl ln -s /usr/local/openssl/lib/libssl.so /usr/lib64/libssl.so echo "/usr/local/openssl/lib" >> /etc/ld.so.conf ldconfig -v #查看版本 openssl version
cd Python-3.10.0
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
make & make install
/usr/local/bin/pip3 install PyMySQL
最后测试是否正常如下:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。