Linux编译安装Python

Linux编译安装Python3.10

部署

#下载解压
wget https://www.python.org/ftp/python/3.10.13/Python-3.10.13.tgz
tar -zxvf Python-3.10.13.tgz
#安装库libffi以支持_ctypes
yum install libffi-devel
#进入配置
cd Python-3.10.13
# --prefix路径 
#--enable-shared 启用共享库
#--enable-optimizations:这个选项启用额外的编译标志,以优化Python解释器。
#--with-ensurepip=install:这个选项会在安装Python时包括pip工具
./configure --prefix=/usr/local/python3.10 --enable-shared --enable-optimizations --with-ensurepip=install
#编译安装
make 
make install
#环境变量
echo "export PATH=${PATH}:/usr/local/python3.10/bin"  >> /etc/profile
#备份旧的
mkdir /usr/python-bak
mv /usr/bin/py* /usr/python-bak
mv /usr/python-bak  /usr/bin
#动态库
echo "/usr/local/python3.10/lib" >> /etc/ld.so.conf.d/python3.10.conf
ldconfig
#生效测试
source /etc/profile
python3 --version
#Python 3.10.13
# Linux  Python 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×