目录
错误现象
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
0% | | 4.1kB 17.7MB/s eta 0:00:01Exception:
Traceback (most recent call last):
File "/Library/Python/3.7/site-packages/pip-7.1.0-py3.7.egg/pip/basecommand.py",line 223,in main
status = self.run(options,args)
File "/Library/Python/3.7/site-packages/pip-7.1.0-py3.7.egg/pip/commands/install.py",line 282,in run
requirement_set.prepare_files(finder)
File "/Library/Python/3.7/site-packages/pip-7.1.0-py3.7.egg/pip/req/req_set.py",line 334,in prepare_files
functools.partial(self._prepare_file,finder))
File "/Library/Python/3.7/site-packages/pip-7.1.0-py3.7.egg/pip/req/req_set.py",line 321,in _walk_req_to_install
more_reqs = handler(req_to_install)
File "/Library/Python/3.7/site-packages/pip-7.1.0-py3.7.egg/pip/req/req_set.py",line 491,in _prepare_file
session=self.session)
File "/Library/Python/3.7/site-packages/pip-7.1.0-py3.7.egg/pip/download.py",line 825,in unpack_url
session,File "/Library/Python/3.7/site-packages/pip-7.1.0-py3.7.egg/pip/download.py",line 673,in unpack_http_url
from_path,content_type = _download_http_url(link,session,temp_dir)
File "/Library/Python/3.7/site-packages/pip-7.1.0-py3.7.egg/pip/download.py",line 886,in _download_http_url
_download_url(resp,link,content_file)
File "/Library/Python/3.7/site-packages/pip-7.1.0-py3.7.egg/pip/download.py",line 621,in _download_url
for chunk in progress_indicator(resp_read(4096),4096):
File "/Library/Python/3.7/site-packages/pip-7.1.0-py3.7.egg/pip/utils/ui.py",line 133,in iter
for x in it:
File "/Library/Python/3.7/site-packages/pip-7.1.0-py3.7.egg/pip/download.py",line 586,in resp_read
decode_content=False):
File "/Library/Python/3.7/site-packages/pip-7.1.0-py3.7.egg/pip/_vendor/requests/packages/urllib3/response.py",line 307,in stream
data = self.read(amt=amt,decode_content=decode_content)
File "/Library/Python/3.7/site-packages/pip-7.1.0-py3.7.egg/pip/_vendor/requests/packages/urllib3/response.py",line 267,in read
raise ReadTimeoutError(self._pool,None,'Read timed out.')
ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org',port=443): Read timed out.
方法一:手动指定源
在 pip3 后面跟-i 来指定源,比如用豆瓣的源来安装 web.py 框架:
pip3 install numpy -i https://pypi.doubanio.com/simple/
注意后面要有 /simple/ 目录
国内可用源:
阿里云 :https://mirrors.aliyun.com/pypi/simple/
中国科技大学 :https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) :https://pypi.doubanio.com/simple/
清华大学: https://pypi.tuna.tsinghua.edu.cn/simple/
腾讯源:https://mirrors.cloud.tencent.com/pypi/simple
方法二:更改默认源
需要创建或修改配置文件( linux 的文件在~/.pip/pip.conf , windows 在%HOMEPATH%\pip\pip.ini ),修改内容为:
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
如果不加后面的 install
则需要每次在命令后面加上 --trusted-host
方法三:手动设置延时
需要看包的大小,有时可以下载下来,有时会卡住
pip3 --default-timeout=1000 install numpy
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。