centos6.9和centos7安装Python3.7.3流程:
Python3.7需要的openssl的版本为1.0.2或者1.1.x,这个requirements在config Python3.7的时候使用“--with-ssl”选项会报出
所以先升级openssl
1、安装依赖
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
yum -y install gcc gcc-c++ libstdc++-devel
2、上传openssl-1.1.1a.tar.gz
mkdir -p /down/python
上传OpenSSL包
tar -zxvf openssl-1.1.1a.tar.gz
cd openssl-1.1.1a
3、编译安装
./config --prefix=/usr/local/openssl no-shared no-zlib
make && make install
4、备份原OpenSSL配置
mv /usr/bin/openssl /usr/bin/openssl_bak
mv /usr/include/openssl/ /usr/include/openssl_bak
5、为新版OpenSSL配置软连接
将安装好的openssl的openssl命令软连到/usr/include/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
软链到升级后的libssl.so
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/local/lib64/libssl.so
将安装好的openssl命令软连到/usr/bin/openssl
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
6、修改系统配置
写入openssl库文件的搜索路径
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
使修改后的/etc/ld.so.conf生效
ldconfig -v
7、验证结果
openssl version
安装Python3.7.3
1、切到安装目录
cd /down/python
上传Python3.7.3的压缩包
tar -zxvf Python-3.7.3.tgz
cd Python-3.7.3
2、编译安装
./configure --prefix=/usr/local/python373 --with-openssl=/usr/local/openssl
make && make install
3、添加软连接
如果之前安装过,需要把之前的删除掉
rm -rf /usr/bin/python3
rm -rf /usr/bin/pip3
ln -s /usr/local/python373/bin/python3 /usr/bin/python3
ln -s /usr/local/python373/bin/pip3 /usr/bin/pip3
4、查看验证
python3 -V
pip3 -V
测试
pip3 install requests
注:如需需要安装Python依赖库,选用豆瓣的镜像比较快
pip3 install grpcio -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
需要安装的依赖库(看自己需求)
grpcio==1.26.0
ledapy==1.2
lightgbm==2.3.1
matplotlib==3.1.2
numpy==1.18.1
pandas==1.0.0
protobuf==3.11.2
flask=*
sympy==1.5.1
gunicorn==20.0.4
依次安装就行
如果是离线方案:待研究