源码安装python3.7

背景

yum无法直接安装python3.7版本,于是尝试从源码直接编译安装,记录一下编译过程,一边后续查阅参考。

安装

下载源码

https://docs.python.org/3/using/unix.html#building-python

编译

./configure --enable-shared --enable-optimizations
make 
make install

验证

python3,报错:

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

原因:
默认情况下会将python3.7的动态库安装在/usr/local/lib目录下,该目录ldconf不识别所以找到该库。
解决方案:

vim /etc/ld.so.conf.d/python3.7.conf
添加一行:
/usr/local/lib
ldconfg

重新启动python3,成功。

猜你喜欢

转载自www.cnblogs.com/lit10050528/p/13388394.html