Python:pip install requests出错解决
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Users\shan>e:
E:\>pip install requests
Collecting requests
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))
after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.or
g', port=443): Read timed out. (read timeout=15)")': /simple/requests/
Could not find a version that satisfies the requirement requests (from versions: )
No matching distribution found for requests
You are using pip version 19.0.3, however version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
pip install requests 出现如上内容,就是无法安装的意思!该如何解决?方法分为临时方法和一劳永逸。
临时方法:(调用第三方)
pip install requests -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
一劳永逸方法:(更换国内安装源,配置到本地)
在windows中:
直接在user目录中创建一个pip目录,如:C:\Users\xx(电脑用户名)\pip,新建文件pip.ini
pip.ini里添加内容
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com
Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)
在文件上写入上面配置文件中的内容
再次进行E:\>pip install requests命令后,可以安装正常了!