python 永久解决pip 访问失败问题

背景

想要使用python完成爬虫,故而需要搭建环境

pip命令

>pip install pyspider

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', PermissionError(13, 'Permission d
enied'))': /simple/pyspider/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', PermissionError(13, 'Permission d
enied'))': /simple/pyspider/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', PermissionError(13, 'Permission d
enied'))': /simple/pyspider/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', PermissionError(13, 'Permission d
enied'))': /simple/pyspider/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', PermissionError(13, 'Permission d
enied'))': /simple/pyspider/
ERROR: Could not find a version that satisfies the requirement pyspider (from versions: none)
ERROR: No matching distribution found for pyspider

python 永久解决pip 访问失败问题

 报错原因

PIP镜像仓库访问不到

 临时解决

# 临时使用
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider

 持久解决

 配置镜像仓库

 python 永久解决pip 访问失败问题

 
需配置其中一个即可

## 配置中科大镜像
pip config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple

# 配置阿里源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
# 配置腾讯源
pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple
# 配置豆瓣源
pip config set global.index-url http://pypi.douban.com/simple/

执行配置之后,会把配置文件写到指定的路径下 

默认路径为: %AppData%\pip\pip.ini

python 永久解决pip 访问失败问题

再次执行

 pip install pyspider

python 永久解决pip 访问失败问题

将镜像源设置为信任

在默认的pip.ini中 增加配置

[global]
index-url = http://pypi.douban.com/simple/
trusted-host = pypi.douban.com

正常执行 

python 永久解决pip 访问失败问题

上一篇:国内镜像源 sources


下一篇:python:virtualenv生成虚拟环境、pip freeze导出依赖、用国内源加速安装导出的依赖requirements.txt、设置永久国内源