Fork me on Gitee

CentOS 7.X 升级 Python 3.9.5

1. 安装依赖关系
 
yum -y install gcc python36-devel bzip2-devel sqlite-devel openssl-devel readline-devel xz-devel xz-devel tk-devel gdbm-devel libffi-devel


2. 下载和安装python包


cd /usr/local/src
wget https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz
tar zxvf Python-3.9.5.tgz
cd Python-3.9.5/
./configure --prefix=/usr/local/python3.9 --with-ssl
make && make install

3. 修改软连接
    1. ln -fs /usr/local/python3.9/bin/python3.9 /usr/bin/python
      ln -fs /usr/local/python3.9/bin/python3.9 /usr/bin/python3
      ln -fs /usr/local/python3.9/bin/pip3.9 /usr/bin/pip
      ln -fs /usr/local/python3.9/bin/pip3.9 /usr/bin/pip3

    2. 5.修改yum文件

    3. vi /usr/bin/yum
      vi /usr/libexec/urlgrabber-ext-down 第一行改都修改为: (原因是安装了python3.8,CentOS 7.X 自带的yum采用的是python2.X,当系统将python升级到2.7 或3.X后,出现语法解释错误)

    4. #!/usr/bin/python2.7

    5. 6.升级pip

    6. python -m pip install --upgrade pip


出现错误必须:

ln -fs /usr/local/python3.9/bin/python3.9 /usr/bin/python
ln -fs /usr/local/python3.9/bin/python3.9 /usr/bin/python3
ln -fs /usr/local/python3.9/bin/pip3.9 /usr/bin/pip
ln -fs /usr/local/python3.9/bin/pip3.9 /usr/bin/pip3

 

必须

 

# 顺手解决 Can't locate Tcl/Tk libs and/or headers
sudo yum install tcl-devel tk-devel
# 解决_ssl问题
sudo yum install openssl-devel

网上的加什么网关方法都是不行的记住了,忙了半个小时
posted @ 2021-12-26 00:51  ---dgw博客  阅读(1828)  评论(1编辑  收藏  举报