centos7安装pip

本文详细介绍了在Linux环境下解决Python Pip安装及更新过程中遇到的各种问题,包括安装失败、证书确认问题、设置国内源等,提供了具体步骤和命令,确保Pip能够顺利安装和使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、通过yum -y install python-pip命令进行安装提示没有可用软件包 python-pip,如下图所示:

已加载插件:fastestmirror, langpacks
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                                                                                                                      | 3.6 kB  00:00:00     
bintray--sbt-rpm                                                                                                                                                                                                          | 1.3 kB  00:00:00     
extras                                                                                                                                                                                                                    | 2.9 kB  00:00:00     
updates                                                                                                                                                                                                                   | 2.9 kB  00:00:00     
(1/2): updates/7/x86_64/primary_db                                                                                                                                                                                        | 1.9 MB  00:00:00     
bintray--sbt-rpm/primary       FAILED                                          
https://sbt.bintray.com/rpm/repodata/92fda36802b79cc2ba1b093f9815757d5da4d35c-primary.xml.gz: [Errno 12] Timeout on https://sbt.bintray.com/rpm/repodata/92fda36802b79cc2ba1b093f9815757d5da4d35c-primary.xml.gz: (28, 'Operation timed out after 30000 milliseconds with 0 out of 0 bytes received')
正在尝试其它镜像。
(2/2): bintray--sbt-rpm/primary                                                                                                                                                                                           | 4.5 kB  00:00:01     
bintray--sbt-rpm                                                                                                                                                                                                                           41/41
没有可用软件包 python-pip。
错误:无须任何处理
2、接着执行:yum -y install epel-release python-pip命令,如下图所示:

3、最后在次执行:yum -y install python-pip即可成功,如下图所示:

4、然后可通过pip -V查看版本,如下图所示:

5、然后通过:pip install --upgrade pip --user进行升级,如下图所示:

6、然后在执行:pip install --upgrade pip,如下图所示:

7、此时在看版本即可升级成功,如下图所示:

8、然后就可以通过

python3 -m pip install XXX或python2 -m pip install XXX安装对应的版本了。

注意:使用此命令可以安装对应不同的python版本

9、当出现Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443)时,如下图所示:

此问题是url的来源的问题,换成了国内的pip源即可

10、选择阿里云的url,执行:python -m pip install chardet -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com即可

如下图所示:

11、设置默认源,首先在~/创建一个.pip文件夹,如下图所示:

12、然后在.pip文件夹中新建一个pip.conf文件,文件内容如下:

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

如下图所示:

13、保存退出,然后执行python -m pip install matplotlib即可,如下图所示:

此时发现已经是从阿里云地址下载了。

14、如果安装的包需要指定版本,可以通过python2 -m pip install numpy==1.16.5指定版本安装,如下图所示:

相关的url源有:

1)http://mirrors.aliyun.com/pypi/simple/ 阿里云

2)https://pypi.mirrors.ustc.edu.cn/simple/  中国科技大学

3) http://pypi.douban.com/simple/  豆瓣

4) https://pypi.tuna.tsinghua.edu.cn/simple/ 清华大学

5)  http://pypi.mirrors.ustc.edu.cn/simple/ 中国科学技术大学

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值