使用pip/pip3安装第三方模块,出现Cannot unpack file xxx的问题的解决以及pip安装速度慢或出现readtime out问题的解决。

本方法应该适应于mac和linux和windows,因为我mac上是有多个版本的,所以我在使用pip3,大家灵活搭配.

1.使用常规方法安装模块

pip3 install requests

2.显示time_out,也就是超时,这种问题,一般用国内源就好了.我使用的是豆瓣源.

pip3 install https://pypi.doubanio.com/simple/ requests

但是使用这种方法提示:

Cannot unpack file /private/var/folders/3n/vbc9phdd7k1fsdj1p4x90kzw0000gn/T/pip-unpack-cf6vtali/simple.htm (downloaded from /private/var/folders/3n/vbc9phdd7k1fsdj1p4x90kzw0000gn/T/pip-req-build-6mac1w3c, content-type: text/html); cannot detect archive format

Cannot determine archive format of /private/var/folders/3n/vbc9phdd7k1fsdj1p4x90kzw0000gn/T/pip-req-build-6mac1w3c

附上终端显示情况:

翻找了一下解决方案,最终用以下方案搞定:

别人的解决方案是使用的清华源:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn requests

但是经过使用它又会报错:

扫描二维码关注公众号,回复: 10330919 查看本文章

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/3.7/site-packages/certifi'

Consider using the `--user` option or check the permissions.

于是给它前面添加sudo最高权限

sudo pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn requests

完美安装.

经过分析发现主要是其--trusted-host解决的问题

也就是说可以这么使用

sudo pip3 install --trusted-host https://pypi.doubanio.com/simple/ requests

完美解决

发布了85 篇原创文章 · 获赞 1 · 访问量 2270

猜你喜欢

转载自blog.csdn.net/qq_37463791/article/details/105086456
今日推荐