python pip下载安装一半退出_Python- 解决PIP下载安装时因为网络速度慢而导致失败的方法...

本文介绍了如何解决国外Python包下载慢和安装失败的问题,建议使用国内镜像源来加速和提高安装成功率。提供了清华大学、阿里云、中国科技大学等镜像地址,并详细说明了在Linux和Windows系统下配置永久镜像源的方法。针对安装失败的常见问题,如网络问题或pip版本过旧,给出了相应的解决方案,包括更新pip、安装wheel以及使用指定镜像源安装。

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

国外的源下载速度太慢,而且经常出现下载后安装出错问题。把PIP安装源替换成国内镜像,可以大幅提升下载速度,还可以提高安装成功率。

国内源:

新版ubuntu要求使用https源,要注意。

清华:https://pypi.tuna.tsinghua.edu.cn/simple

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

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

华中理工大学:http://pypi.hustunique.com/

山东理工大学:http://pypi.sdutlinux.org/

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

临时使用:

可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple

例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,这样就会从清华这边的镜像去安装pyspider库。

永久修改,一劳永逸:

Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)

内容如下:

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]

trusted-host=mirrors.aliyun.com

windows下,在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini。内容同上。

pip 安装模块失败问题

1.先在命令行中输入安装 wheel

pip3 install wheel

问题1:

ERROR: Could not find a version that satisfies the requirement xlwt (from vers

ions: none)

ERROR: No matching distribution found for xlwt

原因:网络问题或者是pip版本需要更新

pip升级:python -m pip install --upgrade pip

网络问题更换金镜像源:pip install https://pypi.tuna.tsinghua.edu.cn/simple 模块名

按照上述操作后,出现了问题2

报错: ERROR: Cannot unpack file c:\users\admini~1\appdata\local\temp\pip-unpack-uwt0

as\simple (downloaded from c:\users\admini~1\appdata\local\temp\pip-req-build-7m

zbzm, content-type: text/html; charset=utf-8); cannot detect archive format

ERROR: Cannot determine archive format of c:\users\admini~1\appdata\local\temp\p

ip-req-build-7mzbzm

使用以下命令安装成功:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn 模块名

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值