背景
想要使用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
报错原因
PIP镜像仓库访问不到
临时解决
# 临时使用
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider
持久解决
配置镜像仓库
需配置其中一个即可
## 配置中科大镜像
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
再次执行
pip install pyspider
将镜像源设置为信任
在默认的pip.ini中 增加配置
[global]
index-url = http://pypi.douban.com/simple/
trusted-host = pypi.douban.com
正常执行