【Python】python2.7升级到python3.x

1.检查当前python版本

python -v

在这里插入图片描述

2.下载最新的python

python下载地址:

wget https://www.python.org/ftp/python/3.12.2/Python-3.12.2.tar.xz
  • 进行解压
tar -xvf Python-3.12.2.tar.xz
  • 系统更新并安装依赖包
yum update -y
yum install -y make gcc gcc-c++
  • 进行编译
cd Python-3.12.2
./configure

在这里插入图片描述

  • 进行安装
make
make install

在这里插入图片描述

  • 将原来的python的软连接重命名:
mv /usr/bin/python /usr/bin/python.bak
  • 添加软链
ln -s /data/tool/Python-3.12.2/python /usr/bin/python

在这里插入图片描述

3. pip安装

wget https://bootstrap.pypa.io/get-pip.py

4.系统默认python调整

  • 修改为python2.7
vim /usr/bin/yum
#!/usr/bin/python2.7

5 .错误

  • Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=‘pypi.org’, port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)) - skipping
安装 openssl-1.1.1
下载openssl1.1.1
 
wget https://www.openssl.org/source/openssl-1.1.1n.tar.gz --no-check-certificate 
解压
tar -zxf openssl-1.1.1n.tar.gz 
进入目录
cd openssl-1.1.1n
设置安装目录 可以自定义 但是要记住,后面会用到
./config --prefix=/data/software/openssl
编译并安装
make -j && make install 
 
 
cd /data/package/Python-3.11.5
make  clean
./configure --prefix=/data/software/python3 --with-openssl=/data/software/openssl --with-openssl-rpath=auto
make -j && make install
  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Crypto Ascetic

您的鼓励是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值