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

相关文章
相关标签/搜索