虚拟机centos7下安装Python3.7

首先配置centos7的镜像源

centos 源_如何修改下载软件源
该方法若不适用的话可自行百度更改

然后安装Python37

采用的是这个的包和过程
https://www.jianshu.com/p/f0d3bf2e43c5
然而在编译安装python3时候有一点要注意。
./configure --prefix=/usr/local/python3 --enable-optimizations
需要改为
./configure --prefix=/usr/local/python36 --enable-shared --with-ssl

按照上面安装Python37有个坑

执行python3 报错:

python3: error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file

解决方案
添加库的配置信息,将python/lib的绝对路径(一般为:’/usr/python/lib’),添加至conf文件中。
切换至/etc/ld.so.conf.d目录下,打开python3.conf文件:
https://blog.csdn.net/nibonnn/article/details/103999157

posted @ 2022-03-03 15:55  索匣  阅读(150)  评论(0编辑  收藏  举报