Linux—yum安裝python-pip


centos下安裝pip時失敗:

[root@wfm ~]# yum -y install pip
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
Setting up Install Process
No package pip available.
Error: Nothing to do

解決方法:

  

需要先安裝擴展源EPEL。

EPEL(http://fedoraproject.org/wiki/EPEL) 是由 Fedora 社區打造,為 RHEL 及衍生發行版如 CentOS、Scientific Linux 等提供高質量軟件包的項目。

首先安裝epel擴展源:

sudo yum -y install epel-release

如果,出現問題可以卸載重裝epel-release:

1.yum remove epel-release
2.清空epel目錄:rm -rf /var/cache/yum/x86_64/6/epel/
3.安裝,yum install  epel-release



然后再安裝pip

~]# sudo yum -y install python-pip
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
epel/metalink | 4.9 kB 00:00 
* base: mirrors.tuna.tsinghua.edu.cn
* epel: mirrors.neusoft.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
epel | 4.3 kB 00:00 
epel/primary_db | 5.8 MB 00:07 
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package python-pip.noarch 0:7.1.0-1.el6 will be installed
--> Processing Dependency: python-setuptools for package: python-pip-7.1.0-1.el6.noarch
--> Running transaction check
---> Package python-setuptools.noarch 0:0.6.10-3.el6 will be installed
--> Finished Dependency Resolution

 
        

Dependencies Resolved

 
        

================================================================
Package Arch Version Repository
Size
================================================================
Installing:
python-pip noarch 7.1.0-1.el6 epel 1.5 M
Installing for dependencies:
python-setuptools noarch 0.6.10-3.el6 base 336 k

 
        

Transaction Summary
================================================================
Install 2 Package(s)

 
        

Total download size: 1.9 M
Installed size: 8.1 M
Downloading Packages:
(1/2): python-pip-7.1.0-1.el6.noarch.rpm | 1.5 MB 00:01 
(2/2): python-setuptools-0.6.10-3.el6.no | 336 kB 00:00 
----------------------------------------------------------------
Total 755 kB/s | 1.9 MB 00:02 
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Importing GPG key 0x0608B895:
Userid : EPEL (6) <epel@fedoraproject.org>
Package: epel-release-6-8.noarch (@extras)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : python-setuptools-0.6.10-3.el6.noarch 1/2 
Installing : python-pip-7.1.0-1.el6.noarch 2/2 
Verifying : python-pip-7.1.0-1.el6.noarch 1/2 
Verifying : python-setuptools-0.6.10-3.el6.noarch 2/2

 
        

Installed:
python-pip.noarch 0:7.1.0-1.el6

 
        

Dependency Installed:
python-setuptools.noarch 0:0.6.10-3.el6

 
        

Complete!

 

OK 成功!



如果安裝報錯:pip安裝pkg_resources.DistributionNotFound: pip==9.0.1   #參考:https://blog.csdn.net/daiyutage/java/article/details/69945850

執行pip命令報錯

Traceback (most recent call last):
File "./pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/opt/soft/distribute-0.7.3/pkg_resources.py", line 2989, in <module>
working_set.require(__requires__)
File "/opt/soft/distribute-0.7.3/pkg_resources.py", line 726, in require
needed = self.resolve(parse_requirements(requirements))
File "/opt/soft/distribute-0.7.3/pkg_resources.py", line 624, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==9.0.1

 

應該是缺少pip9.0.1
執行easy_install pip==9.0.1又報錯

Traceback (most recent call last):
File "/usr/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "/opt/soft/distribute-0.7.3/pkg_resources.py", line 2993, in <module>
parse_requirements(__requires__), Environment()
File "/opt/soft/distribute-0.7.3/pkg_resources.py", line 624, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: distribute==0.6.10


再安裝distribute包

wget http://pypi.python.org/packages/source/d/distribute/distribute-0.6.10.tar.gz
cd distribute-0.6.10
python setup.py install


再次安裝pip9.0.1

easy_install pip==9.0.1

安裝成功

Adding pip 9.0.1 to easy-install.pth file
Installing pip script to /usr/local/python2.7/bin
Installing pip2.7 script to /usr/local/python2.7/bin
Installing pip2 script to /usr/local/python2.7/bin

Installed /usr/local/python2.7/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg
Processing dependencies for pip==9.0.1
Finished processing dependencies for pip==9.0.1

運行pip

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM