Centos7源码安装Python3
原文:https://zhuanlan.zhihu.com/p/590965831
下载安装包
wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz tar -xzf Python-3.11.0.tgz
安装源码编译需要的编译环境
yum -y install gcc zlib zlib-devel libffi libffi-devel readline-devel openssl-devel openssl11 openssl11-devel
设置编译FLAG,以便使用最新的openssl库
export CFLAGS=$(pkg-config --cflags openssl11) export LDFLAGS=$(pkg-config --libs openssl11)
进入刚解压缩的目录
cd ./Python-3.11.0
指定python3的安装目录为 /usr/python 并使用ssl模块,指定目录好处是后期删除此文件夹就可以完全删除软件了。
./configure --prefix=/usr/python --with-ssl make make install
指定链接,此后我们系统的任何地方输入python3就是我们安装的
ln -s /usr/python/bin/python3 /usr/bin/python3 ln -s /usr/python/bin/pip3 /usr/bin/pip3
发表评论