centos7安装python3.11
2023-12-13 05:32:52
1 安装依赖
sudo yum -y update
sudo yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel psmisc libffi-devel -y
sudo yum -y groupinstall "Development Tools"
2 安装必需的 openssl >= 1.1.1
wget https://www.openssl.org/source/openssl-1.1.1q.tar.gz --no-check-certificate
tar zxf openssl-1.1.1q.tar.gz
cd openssl-1.1.1q
./config --prefix=/usr/local/openssl-1.1.1
sudo make && sudo make install
3 安装python3.11.2
# 下载
wget https://www.python.org/ftp/python/3.11.2/Python-3.11.2.tgz
# 解压
tar -xf Python-3.11.2.tgz
# 进入目标文件
cd Python-3.11.2
# 配置安装路径:/usr/local/python311
# 把python3.11.2 编译安装到/usr/local/python311路径下
./configure --prefix=/usr/local/python311
# 编译并安装,如果报错,说明缺依赖
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel psmisc libffi-devel zlib* libffi-devel -y
make && make install
# 建立软连接:/usr/local/python311路径不在环境变量,终端命令 python3,pip3
cd /usr/local/python311/bin
ln -s /usr/local/python311/bin/python3 /usr/bin/python3
ln -s /usr/local/python311/bin/pip3 /usr/bin/pip3
# 机器上有多个python和pip命令,对应关系如下
python 2.x pip
python3 3.6 pip3
python3.11 3.11 pip3.11
# 删除安装包与文件:
rm -rf Python-3.11.2
rm -rf Python-3.11.2.tgz
注意:使用pip3,报错
1 先安装EPEL
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
2 将原有的备份epel.repo和epel-testing.repo
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.back
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.back
3 重新安装epel.repo
sudo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
4 再运行如下命令,安装pip3
sudo yum install python3-pip
文章来源:https://blog.csdn.net/weixin_44145338/article/details/134887830
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!