Centos7自带Python 2.7.5无法使用pip命令

1.解决办法

  • yum源已经配好
  • 安装号Centos7系统后,自动会自带Pyhon 2.7.5,默认没有pip命令,解决办法参考如下。

1. 1 查看Python版本,默认版本Python 2.7.5

[root@localhost local]# python 
Python 2.7.5 (default, Aug  7 2019, 00:51:29) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

#输入pip list系统提示命令没有找到
[root@localhost local]# pip list 
bash: pip: command not found...

#输入yum install python-pip,提示没有可用 python-pip
[root@localhost local]# yum install python-pip
No package python-pip available.

1.2 执行安装yum -y install epel-release命令

[root@localhost local]# yum -y install epel-release
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                Arch             Version         Repository        Size
================================================================================
Installing:
 epel-release           noarch           7-11            extras            15 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 15 k
Installed size: 24 k
Downloading packages:
epel-release-7-11.noarch.rpm                               |  15 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-11.noarch                                     1/1 
  Verifying  : epel-release-7-11.noarch                                     1/1 

Installed:
  epel-release.noarch 0:7-11                                                    

Complete!

1.3 再次执行yum install python-pip命令

[root@localhost local]# yum install python-pip
Existing lock /var/run/yum.pid: another copy is running as pid 3308.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory : 206 M RSS (626 MB VSZ)
    Started: Tue Jan 21 10:53:57 2020 - 00:08 ago
    State  : Running, pid: 3308
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory : 260 M RSS (680 MB VSZ)
    Started: Tue Jan 21 10:53:57 2020 - 00:10 ago
    State  : Sleeping, pid: 3308
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory : 260 M RSS (680 MB VSZ)
    Started: Tue Jan 21 10:53:57 2020 - 00:12 ago
    State  : Sleeping, pid: 3308
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory : 260 M RSS (680 MB VSZ)
    Started: Tue Jan 21 10:53:57 2020 - 00:14 ago
    State  : Sleeping, pid: 3308
Resolving Dependencies
--> Running transaction check
---> Package python2-pip.noarch 0:8.1.2-10.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package              Arch            Version               Repository     Size
================================================================================
Installing:
 python2-pip          noarch          8.1.2-10.el7          epel          1.7 M

Transaction Summary
================================================================================
Install  1 Package

Total download size: 1.7 M
Installed size: 7.2 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/epel/packages/python2-pip-8.1.2-10.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for python2-pip-8.1.2-10.el7.noarch.rpm is not installed
python2-pip-8.1.2-10.el7.noarch.rpm                        | 1.7 MB   00:00     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <[email protected]>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-11.noarch (@extras)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python2-pip-8.1.2-10.el7.noarch                              1/1 
  Verifying  : python2-pip-8.1.2-10.el7.noarch                              1/1 

Installed:
  python2-pip.noarch 0:8.1.2-10.el7                                             

Complete!

1.4 安装好pip进行升级:pip install --upgrade pip

[root@localhost local]# pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl (1.4MB)
  .             .. 忽略中间日志...
Installing collected packages: pip
  Found existing installation: pip 8.1.2
    Uninstalling pip-8.1.2:
      Successfully uninstalled pip-8.1.2
Successfully installed pip-19.3.1

1.5 使用pip测试,安装成功

[root@localhost local]# pip list
backports.ssl-match-hostname (3.5.0.1)
blivet (0.61.15.74)
Brlapi (0.6.0)
chardet (2.2.1)
chrome-gnome-shell (0.0.0)
configobj (4.7.2)
coverage (3.6b3)
cupshelpers (1.0)
decorator (3.4.0)
...
发布了10 篇原创文章 · 获赞 1 · 访问量 843

猜你喜欢

转载自blog.csdn.net/Sky_Mazarine/article/details/104059884