pip最新源总结及pip常见问题解决方法(亲测有效)

本文介绍了如何更换Python包管理工具pip的源,包括阿里云、中国科技大学、豆瓣、清华大学等镜像,并提供了针对模块缺失、下载缓慢、源中无模块等问题的解决方法。同时,详细阐述了临时与永久修改pip源的方法,以及处理下载过程中可能出现的各种错误。

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

一、简介

本文主要整理了pip常用的源地址以及在使用pip过程中报错的解决方法。
1 、模块缺少错误
2、 下载模块过程网速较慢中止
3、 源中无该模块
4、 更换不同源一直没有该模块

二、常用源总结

//阿里云
https://mirrors.aliyun.com/pypi/simple/ 
//中国科技大学
https://pypi.mirrors.ustc.edu.cn/simple/ 

//豆瓣(douban)
https://pypi.douban.com/simple/ 
//清华大学
https://pypi.tuna.tsinghua.edu.cn/simple/ 
//中国科学技术大学
https://pypi.mirrors.ustc.edu.cn/simple/
//官方源
https://pypi.python.org/simple

三、更换源方式

3.1 临时使用方式:

pip install scrapy -i  http://mirrors.aliyun.com/pypi/simple/

3.2 永久修改源地址:

vim  ~/.pip/pip.conf   // (没有就创建一个), 内容如下:

[global]
index-url =  https://pypi.douban.com/simple/ 

2、命令设置源地址:

pip config set global.index-url  http://mirrors.aliyun.com/pypi/simple/ 

四、常见问题处理

4.1 模块缺少错误

Traceback (most recent call last):
File "fwpkg.py", line 4, in <module>
from Crypto.Hash import SHA256
ImportError: No module named Crypto.Hash
make: *** [Makefile:50:loader] 错误 1
//解决方法:
pip install pycrypto

4.2 下载模块过程网速较慢中止

在这里插入图片描述

//解决方法:更换其他源,个人喜欢用豆瓣源,感觉速度比较快
pip install pycrypto  -i http://pypi.douban.com/simple/  

若报错为该源未添加信任,追加–trusted-host pypi.douban.com即可:

root@VirtualBox:/# pip install pycrypto  -i http://pypi.douban.com/simple/ 
Looking in indexes: http://pypi.douban.com/simple/
WARNING: 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 we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host pypi.douban.com'.
//解决方法:
root@VirtualBox:/# pip install pycrypto  -i http://pypi.douban.com/simple/  --trusted-host pypi.douban.com

4.3 源中无该模块

root@VirtualBox:/# pip install cStringIO
ERROR: Could not find a version that satisfies the requirement cStringIO (from versions: none)
ERROR: No matching distribution found for cStringIO
解决方法:可以通过pip list查看该源下有的模块,若没有则更换其他源 

4.4 更换不同源一直没有该模块

考虑是否为python版本问题,本人遇到过用python3的版本一直没有cStringIO模块,因为默认用的python3的版本,此时可以更改默认使用的python版本,命令如下:

//创建/usr/bin/python软连接指向/usr/bin/python2.7:
ln -sf /usr/bin/python2.7 /usr/bin/python
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值