centos下安裝pip以及使用

在使用centos7的軟件包管理程序yum安裝python-pip的時候會報一下錯誤:python

No package python-pip available.
Error: Nothing to do
說沒有python-pip軟件包能夠安裝。

這是由於像centos這類衍生出來的發行版,他們的源有時候內容更新的比較滯後,或者說有時候一些擴展的源根本就沒有。
因此在使用yum來search  python-pip的時候,會說沒有找到該軟件包。所以爲了可以安裝這些包,須要先安裝擴展源EPEL。
EPEL(http://fedoraproject.org/wiki/EPEL) 是由 Fedora 社區打造,爲 RHEL 及衍生髮行版如 CentOS、Scientific Linux 等提供高質量軟件包的項目。
首先安裝epel擴展源:docker

sudo yum -y install epel-release

而後安裝python-pipcentos

sudo yum -y install python-pip

安裝完以後別忘了清除一下cachebash

sudo yum clean all

搞定,收工!ui

使用this

每每安裝完pip後,直接pip install xxx,會很慢或者超市,次數能夠更新下源url

編輯~/.pip/pip.confcentos7

[global]
index-url=http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com

而後在pip install就很快了。code

忽然有一天,執行pip install xxx時,提示:ip

[root@localhost ~]# pip install requests
Collecting requests
  The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host pypi.douban.com'.
  Could not find a version that satisfies the requirement requests (from versions: )
No matching distribution found for requests

這是,能夠在pip命令後添加「--trusted-host pypi.douban.com」

pip install --trusted-host pypi.douban.com

解決。

pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com docker-compose

相關文章
相關標籤/搜索