问题如下:
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f3927b66898>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/scrapy/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f3927b66550>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/scrapy/
一开始我以为是pip的安装源问题:
于是我就临时修改了源:
临时使用:pip install pythonModuleName(python库名) -i https://pypi.douban.com/simple(豆瓣源)
但是并没有上面x用
于是我干脆就修改了默认的安装源(国内的镜像下载确实要快一点)
新建文件夹 mkdir -p ~/.pip
新建配置文件 vim ~/.pip/pip.conf
内容如下(我这里用的是豆瓣,可以根据自己想用的选择,网上可以搜索):
[global]
index-url=https://pypi.douban.com/simple/
[install]
use-mirrors=true
mirrors=https://pypi.douban.com/simple/
trusted-host=pypi.douban.com
到这里其实问题大部分人的问题所在了,但我就比较厉害,不是!!!
后来仔细看一下,发现原来是DNS配置错误,于是我就这样干了:
sudo vim /etc/resolv.conf
在打开的内容下加上:
nameserver 8.8.8.8
问题解决!!!