在使用centos7的软件包管理程序yum安装python-pip的时候会报一下错误:
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扩展源:
sudo yum -y install epel-release
然后安装python-pip
sudo yum -y install python-pip
安装完之后别忘了清除一下cache
sudo yum clean all
搞定,收工!
使用
往往安装完pip后,直接pip install xxx,会很慢或者超市,次数可以更新下源
编辑~/.pip/pip.conf
[global]
index-url=http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
然后在pip install就很快了。
突然有一天,执行pip install xxx时,提示:
[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