今天一天,被python2和python3.8和yum搞得焦头烂额了,特来记录一下,我举得,这是一个历史性的问题,好多人都存在这样的问题,
查看系统版本
cat /etc/redhat-release
卸载pyhton3
rpm -qa|grep python3|xargs rpm -ev --allmatches --nodeps
删除所有残余文件
whereis python3 |xargs rm -frv
python3 查看是否存在
配置环境变量
vim ~/.bash_profile
添加一句: export PATH=$PATH:/usr/local/bin
source ~/.bash_profile
python2.7的乱链接以及pip的安装(find / -name pip)
sudo ln -s /usr/bin/python2.7 /usr/bin/python
curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
sudo ln -s /usr/bin/python2.7 /usr/bin/python
sudo ln -s /usr/bin/pip /usr/bin/pip
删除yum
rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps
rm -rf /etc/yum.repos.d/*
whereis yum|xargs rm -fr
python3.9的安装
一下方法不可用,可参考:
https://editor.csdn.net/md/?articleId=121077598
需要电脑先安装gcc
yum install gcc
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
tar xzf Python-3.9.0tgz
cd Python-3.9.0
./configure --enable-optimizations
make && make install
# 建立软连接
ln -s /usr/local/bin/python3.9 /usr/bin/python3
ln -s /usr/local/bin/pip3.9 /usr/bin/pip3
未完待续…
本文档记录了解决Python2、Python3版本冲突,以及环境配置、yum删除、pip安装和Python3.9安装的详细步骤。包括查看系统版本、卸载Python3、配置环境变量、创建软链接、安装pip,以及删除yum相关文件。

4498

被折叠的 条评论
为什么被折叠?



