1、下载安装gcc
yum install gcc
2、安装依赖项
yum install openssl-devel bizp2-devel expat-devel gdbm-devel readline-devel sqlite-devel libffi-devel
3、下载或者将python3安装包上传至服务器
wget wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
4、解压并进入到python目录
tar -zvxf Python-3.7.3.tgz
cd Python-3.7.3
5、安装和编译
./configure --prefix=/usr/local/python3 --enable-shared CFLAGS=-fPIC
make
make install
6、建立软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
7、可能的报错
python3.7: error while loading shared libraries: libpython3.7m.so.1.0
解决办法
cd Python-3.7.3
cp libpython3.7m.so.1.0 /usr/local/lib64
cp libpython3.7m.so.1.0 /usr/lib
cp libpython3.7m.so.1.0 /usr/lib64
来源:CSDN
作者:weixin_41596463
链接:https://blog.csdn.net/weixin_41596463/article/details/104009557