CentOS 7 安装pip问题解决

安装pip:
1.使用yum进行安装
yum install python-pip

若出现 
No package python-pip available.

解决方法如下:

yum -y install epel-release
yum install python-pip

为什么要先安装epel-release?
RHEL以及他的衍生发行版如CentOS、Scientific Linux为了稳定,官方的rpm repository提供的rpm包往往是很滞后的,当然了,这样做这是无可厚非的,毕竟这是服务器版本,安全稳定是重点,官方的rpm repository提供的rpm包也不够丰富,很多时候需要自己编译那太辛苦了,而EPEL恰恰可以解决这两方面的问题。
EPEL的全称叫 Extra Packages for Enterprise Linux 。EPEL是由 Fedora 社区打造,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目。装上了 EPEL之后,就相当于添加了一个第三方源。
另外一个特点是绝大多数rpm包要比官方repository 的rpm包版本要来得新。
1. 不用去换原来yum源,安装后会产生新repo
2. epel会有很多源地址,如果一个下不到,会去另外一个下
3. 更新时如果下载的包不全,就不会进行安装。这样的话,依赖关系可以保证

为提高pip的安装速度,使用国内的pip源,这里更新pip源为阿里源:

在用户目录中建立pip隐藏目录和配置文件

mkdir ~/.pip/
vim ~/.pip/pip.conf

写入

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

安装flask验证:

pip install flask
很快安装成功。


[root@openstack openstack]# yum install -y python-pip
已加载插件:fastestmirror, langpacks
base                                                                                                                                                                             | 3.6 kB  00:00:00

 One of the configured repositories failed (未知),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:

            yum-config-manager --disable

     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=.skip_if_unavailable=true

Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again

你可能感兴趣的:(Linux)