第一步下载
到python官网下载安装包
https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
解压到/opt目录下

tar -cf Python-3.9.0.tar.xz

cd /opt/Python-3.9.0
执行编译和安装

./configure --prefix=/usr/local/bin/python39  --enable-optimizations  --enable-shared CFLAGS=-fPIC
make && make install


将python3.7改为默认的版本,删除当前软连接
rm -f /usr/bin/python
ln -s /usr/local/bin/python39/bin/python3 /usr/bin/python
执行 
python -V
可能会出现如下错误
./python: error while loading shared libraries: libpython3.9.so.1.0: cannot open shared object file: No such file or directory
解决方式
创建文件添加内容
vim /etc/ld.so.conf.d/python3.conf
/usr/local/bin/python39/lib/
推出保存执行命令
ldconfig

查看python版本信息

python -V

 

最后修改于 2020-11-06 15:50:46
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付
上一篇