搭建环境:Linux的centos系统、Python3.7
- 1.python3.7.4源码包地址:
https://www.python.org/downloads/
- 2.将下载好的包上传到服务器,解压缩
tar -xvzf Python-3.7.4.tgz -C .
- 3.pythoh3创建指定目录
mkdir /usr/local/python3
- 4.配置编译项
./configure --prefix=/usr/local/python3 --enable-shared CFLAGS=-fPIC
- 5.编译和安装
make && make install
-
6.出现Successfully表示python安装成功
- 7.安装成功后创建python3的软连接
mv /usr/bin/python /usr/bin/python_bak
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
8.输入python3进入python环境
若如下错误: 系统找不到外联库导致
python3:error while loading shared libraries:libpython3.7m.so.1.0:cannot open shared object file
执行如下步骤:- 1)
cd /etc/ld.so.conf.d
- 2)
vi python3.conf
- 3)写入如下内容并保存
/usr/local/python3/lib
- 4)执行命令
ldconfig
- 1)