python源码安装

make install的时候,根据提示安装依赖包

yum -y intall zlib zlib-devel libffi-devel tk-devel

1. 下载与解压

wget https://www.python.org/ftp/python/3.9.4/Python-3.9.4.tar.xz
tar xvf Python-3.9.4.tar.xz -C /usr/local/src
cd Python-3.9.4

# 后面make install的时候,根据提示安装依赖包
yum -y intall zlib zlib-devel libffi-devel tk-devel

2. 生成Makefile与编译安装

./configure --prefix=/usr/local/src/python3.9 --enable-optimizations --with-ssl --enable-shared CFLAGS=-fPIC
make & make install

3. 设置全局环境变量

ln -s /usr/local/python3.9/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3.9/bin/pip3 /usr/local/bin/pip3

PS:
error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file

posted @ 2021-05-30 08:35  AlexG  阅读(380)  评论(0编辑  收藏  举报