ERROR: Could not find a version that satisfies the requirement PIL ERROR: No matching distribution found for PIL
代码如下
//pip install PIL
报错
WARNING:Retrying (total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPConnection object at 0x0416ACB0>: Failed to establish a new connection: [Error 11001] getaddrinfo failed')': /simple/pil/
WARNING:Retrying (total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPConnection object at 0x0416A490>: Failed to establish a new connection: [Error 11001] getaddrinfo failed')': /simple/pil/
WARNING:Retrying (total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPConnection object at 0x0416A690>: Failed to establish a new connection: [Error 11001] getaddrinfo failed')': /simple/pil/
WARNING:Retrying (total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPConnection object at 0x0416AC90>: Failed to establish a new connection: [Error 11001] getaddrinfo failed')': /simple/pil/
WARNING:Retrying (total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPConnection object at 0x041953B0>: Failed to establish a new connection: [Error 11001] getaddrinfo failed')': /simple/pil/
ERROR:Could not find a version that satisfies the requirement PIL
ERROR:No matching distribution found for PIL
截图如下
在网上找了原因,说是“pip的时候各种关卡限制其网速导致网速过慢或安装失败”,也就是连接超时,所以需要自己设定安装源,照着网上的方法进行安装:
pip install PIL -i 空格,再加pip源的 url
如果还是报错,要求使用“-trusted host”
国内pip源的url如下,任选一个:
阿里云:http://mirrors.aliyun.com/pypi/simple
豆瓣:http://pypi.douban.com/simple/
清华大学:https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学:https://pypi.mirrors.ustc.edu.cn/simple
e.g. 任选一个pip源 例如清华大学的 代码如下
//pip install PIL -i http://pypi.tuna.tsinghua.edu.cn/simple/
报错
试着在 pip install PIL -i http://pypi.tuna.tsing.edu.cn/simple/
后再加 --trusted-host pypi.tuna.tsing.edu.cn 代码如下
//pip install PIL -i http://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn
还是报错
ERROR: Could not find a version that satisfies the requirement PIL (from versions: none)
ERROR: No matching distribution found for PIL
截图如下
又查了一下,因为 PIL 已经被 Pillow 所替代了,所以使用 pip install PIL 不行,要将其改成 pip install Pillow
//pip install Pillow -i http://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn
终于成功 截图如下
所以最终答案 就是这行代码:
//pip install Pillow -i http://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn
希望可以帮到大家!