进行pip3升级,安装模块时报错如下:
root@ubuntu:~/# pip3 install pymysql
Collecting pymysql
Exception:
Traceback (most recent call last):
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connection.py", line 137, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/util/connection.py", line 67, in create_connection
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution
###此处省略一大串回溯信息........
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
You are using pip version 8.1.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
如上,是一个常见的错误,是由于网络不通的原因引起的报错,建议排查/etc/resolve.conf和/root/.pip/pip.conf两个文件。
1、换一下dns地址。
2、pip.conf里的源换一下,例如换为阿里云的源:
mkdir /root/.pip #如果该目录存在,就不用再创建该目录
echo -e "[global]\nindex-url = https://mirrors.aliyun.com/pypi/simple" >/root/.pip/pip.conf
3、如果不能解决问题,建议按照百度搜到的其他方法如卸载重装pip3