centos7中 yum跟python的安装【附带python3安装】

摘要: centos7中 yum跟python的安装【附带python3安装】 苦逼的一天从敲代码开始,想安装个软件要用到yum 但是之前升级python 把环境搞乱掉了,所以技术不好的还是建议不要覆盖安装python 正好把centos7 安装python3的代码贴出来

centos7中 yum跟python的安装【附带python3安装】 苦逼的一天从敲代码开始,想安装个软件要用到yum  但是之前升级python 把环境搞乱掉了,所以技术不好的还是建议不要覆盖安装python 正好把centos7 安装python3的代码贴出来

mkdir /tmp/python3 -p
cd /tmp/python3
yum install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
yum install libffi-devel -y
wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
tar -zxvf Python-3.7.2.tgz
cd Python-3.7.2
mkdir -p /usr/local/python3
./configure --prefix=/usr/local/python3 #将/usr/local/python3设置为安装目录
make
make install
rm -f /usr/bin/python3
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
yum install python3-pip -y
yum install python3-devel -y
pip3 install --upgrade pip3
pip3 install -i https://pypi.douban.com/simple Pillow
pip3 install -i https://pypi.douban.com/simple requests
pip3 install -i https://pypi.douban.com/simple bs4
pip3 install -i https://pypi.douban.com/simple selenium
pip3 install -i https://pypi.douban.com/simple lxml
pip3 install -i https://pypi.douban.com/simple jieba
pip3 install -i https://pypi.douban.com/simple scrapy
pip3 install -i https://pypi.douban.com/simple redis
pip3 install -i https://pypi.douban.com/simple pymysql
pip3 install -i https://pypi.douban.com/simple threadpool
pip3 install -i https://pypi.douban.com/simple  PyYaml
pip3 install -i https://pypi.douban.com/simple  python-docx
pip3 install -i https://pypi.douban.com/simple  wand
pip3 install -i https://pypi.douban.com/simple  oss2
pip3 install -i https://pypi.douban.com/simple  pywin32
pip3 install -i https://pypi.douban.com/simple  rarfile
pip3 install -i https://pypi.douban.com/simple  asyncTask

以上是直接安装python3 的,接下来回到正题;

  1. 把没卸载干净的卸载干净:    

    1. rpm -e yum-plugin-fastestmirror-1.1.31-52.el7.noarch --nodeps
      rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
      rpm -e yum-utils-1.1.31-52.el7.noarch --nodeps

    2.http://mirrors.163.com/centos/7/os/x86_64/Packages/  下载包 当然我知道大兄弟们都是懒的去一个个找 我直接贴出来了

cd /root && mkdir soft&&cd /root/soft
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/libxml2-python-2.9.1-6.el7.5.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-ipaddress-1.0.16-2.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/lvm2-python-libs-2.02.187-6.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-2.7.5-89.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-libs-2.7.5-89.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-aliases-1.1.31-54.el7_8.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-chardet-2.2.1-3.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-devel-2.7.5-89.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-54.el7_8.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-45.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm

下载完了开始执行安装

rpm -Uvh --replacepkgs lvm2-python-libs*.rpm --nodeps --force
rpm -Uvh --replacepkgs libxml2-python*.rpm --nodeps --force
rpm -Uvh --replacepkgs python*.rpm --nodeps --force
rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm --nodeps --force

image.png


安装好了 我的一下午 也是醉了 做个笔记 记录一下

image.png

如果想自己找的 可以找这些包:

libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm                    
python-ipaddress-1.0.16-2.el7.noarch.rpm  
lvm2-python-libs-2.02.185-2.el7.x86_64.rpm
python-kitchen-1.1.1-5.el7.noarch.rpm     
yum-3.4.3-163.el7.centos.noarch.rpm
python-2.7.5-86.el7.x86_64.rpm                                
python-libs-2.7.5-86.el7.x86_64.rpm       
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm  
python-pycurl-7.19.0-19.el7.x86_64.rpm    
yum-plugin-aliases-1.1.31-52.el7.noarch.rpm
python-chardet-2.2.1-3.el7.noarch.rpm                         
python-setuptools-0.9.8-7.el7.noarch.rpm  
yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
python-devel-2.7.5-86.el7.x86_64.rpm                          
python-urlgrabber-3.10-9.el7.noarch.rpm   
yum-plugin-protectbase-1.1.31-52.el7.noarch.rpm
python-iniparse-0.4-9.el7.noarch.rpm                          
rpm-python-4.11.3-40.el7.x86_64.rpm       
yum-utils-1.1.31-52.el7.noarch.rpm


如果安装完还不能执行yum update 参考一下这篇 :https://www.d1blog.com/linuxyunwei/1929.html





本文由 帝一博客 原创发布。用户在本站发布的原创内容(包括但不仅限于回答、文章和评论),著作权均归用户本人所有。独家文章转载,请联系邮箱:17762131@qq.com。获得授权后,须注明本文地址: https://www.d1blog.com/linuxyunwei/1927.html

网友留言评论

0条评论