Centos7 卸载与重装python3 pip yum
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
文章目录
版本
版本号
# CentOS Linux release 7.7.1908 (Core)
# Python2.7.5
卸载
安装依赖
- 之后重装 Python3.8 需要的
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel gcc
卸载 Python
# 强制删除已安装程序及其关联
rpm -qa|grep python|xargs rpm -ev --allmatches --nodep
# 删除所有残余文件
whereis python |xargs rm -frv
# 验证
whereis python
卸载 yum
# 强制删除已安装程序及其关联
rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
# 删除所有残余文件
whereis yum |xargs rm -frv
重装Python前准备
下载 Python-3.8.0.tgz
https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
Python安装步骤
# 解压
tar -zxvf Python-3.8.0.tgz
# 安装
cd Python-3.8.0
# 指定安装目录,并且编译方式安装
./configure --with-ssl --prefix=/usr/local/python3
make
make install
# 建立软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
# 加入$PATH
vim /etc/profile
- export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin:/usr/local/python3/bin
source /etc/profile
# 验证
python3 -V
pip安装步骤
#通过get-pip.py安装
cd ~
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
# 运行安装
python3 get-pip.py
#创建软链接
ln -s /usr/local/python3/bin/pip /usr/bin/pip3
# 验证
pip3 -V
重装YUM前准备
因Centos7 指定最高 python 版本 再开始时候已经无情的删除了。所以需要重先安装才能运行 yum 指令
编写简易脚本,重装回python2.7.5
cd ~
mkdir python2.7
vim py.txt
-----
# python2.7.5 内容如下
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-2.7.5-86.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-perf-3.10.0-1062.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-schedutils-0.4-6.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/policycoreutils-python-2.5-33.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-firewall-0.6.3-2.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-2.7.5-86.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-decorator-3.4.0-3.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-gobject-base-3.22.0-1.el7_4.1.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-slip-0.4.0-4.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/newt-python-0.52.15-4.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-configobj-4.7.2-7.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-slip-dbus-0.4.0-4.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-pyudev-0.15-9.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/libsemanage-python-2.5-14.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-libs-2.7.5-86.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/libselinux-python-2.5-14.1.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-linux-procfs-0.4.11-4.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/audit-libs-python-2.8.5-4.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-IPy-0.75-6.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/dbus-python-1.1.1-9.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-40.el7.x86_64.rpm
# --nodeps --force为不考虑依赖包,强制安装
rpm -ivh python-* rpm-python-* --nodeps --force
-----
# 赋予脚本权限,并且执行
chown 777 py.txt
sh py.txt
# 验证
python -V
编写简易脚本,重装回YUM与解决使用问题
cd ~
mkdir yum
vim yum.txt
---
# yum需要的包
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm
# 安装
rpm -ivh yum-*
---
# 赋予脚本权限,并且执行
chown 777 yum.txt
sh yum.txt
# redhad7系统原带有Python2导致的问题
vim /usr/bin/yum
vim /usr/libexec/urlgrabber-ext-down
将第一行"#!/usr/bin/python" 改为 "#!/usr/bin/python2"即可
收尾工作
新旧版本互转
# python3.8.0 作为默认
cd /usr/bin
ls -la | grep python
ln -s /usr/local/python3/bin/python3 /usr/bin/python
# pip
cd /usr/bin
ls -la | grep pip
ln -s /usr/local/python3/bin/pip /usr/bin/pip
参考资料
- Centos7 资源下载
- https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
- 参考网站
- https://www.cnblogs.com/wangjunjiehome/p/9239005.html
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献1条内容
所有评论(0)