现在有些库要求 Python 版本在 3.6 以上,因此这里以 Ubuntu 16.04 环境源码升级 Python 版本为Python3.7.3 (Ubuntu 默认 Python=3.5.2).

Ubuntu - 升级Python版本(非源码编译) - AIUAI

1. Python 源码编译安装

如:

sudo ./configure
sudo make clean
sudo make -j4
sudo make install

2. 问题解决

2.1. 问题: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory

编译安装完成后,出现该问题.

解决方法:

cd /etc/ld.so.conf.d/
sudo vim python3.conf
#添加如下内容:
#  /usr/local/lib
sudo /sbin/ldconfig

2.2. 问题: recompile with -fPIC

具体问题:

libpython3.7(abstract.o): relocation R_X86_64_32 against 'a local symbol' can not be used when making a shared object; recompile with -fPIC
/lib/libpython3.7.a: could not read symbols: Bad value

解决方法:

重新编译Python3.7, 如下:

sudo ./configure --prefix=/usr/local/  --enable-shared CFLAGS=-fPIC
sudo make clean
sudo make -j4
sudo make install
Last modification:June 15th, 2019 at 02:27 pm