经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 数据库/运维 » Linux/Shell » 查看文章
pip安装模块使用国内镜像源加速安装
来源:cnblogs  作者:雨夜Rainight  时间:2019/11/7 20:34:25  对本文有异议

今天在安装Python模块matplotlib的时候,一直安装不成功,老是提示“socket.timeout: The read operation timed out”或者“Read timed out.”

因为国内的网络访问国外延迟很高,所以安装模块很慢就不说了,还一定安装不上。

  1. 1 [root@localhosts ~]# pip3 install --user matplotlib
  2. 2 WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
  3. 3 Collecting matplotlib
  4. 4 Downloading https://files.pythonhosted.org/packages/57/4f/dd381ecf6c6ab9bcdaa8ea912e866dedc6e696756156d8ecc087e20817e2/matplotlib-3.1.1-cp36-cp36m-manylinux1_x86_64.whl (13.1MB)
  5. 5 38% |████████████▍ | 5.1MB 11kB/s eta 0:12:11Exception:
  6. 6 Traceback (most recent call last):
  7. 7 File "/usr/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py", line 302, in _error_catcher
  8. 8 yield
  9. 9 File "/usr/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py", line 384, in read
  10. 10 data = self._fp.read(amt)
  11. 11 File "/usr/lib/python3.6/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 60, in read
  12. 12 data = self.__fp.read(amt)
  13. 13 File "/usr/lib64/python3.6/http/client.py", line 459, in read
  14. 14 n = self.readinto(b)
  15. 15 File "/usr/lib64/python3.6/http/client.py", line 503, in readinto
  16. 16 n = self.fp.readinto(b)
  17. 17 File "/usr/lib64/python3.6/socket.py", line 586, in readinto
  18. 18 return self._sock.recv_into(b)
  19. 19 File "/usr/lib64/python3.6/ssl.py", line 968, in recv_into
  20. 20 return self.read(nbytes, buffer)
  21. 21 File "/usr/lib64/python3.6/ssl.py", line 830, in read
  22. 22 return self._sslobj.read(len, buffer)
  23. 23 File "/usr/lib64/python3.6/ssl.py", line 587, in read
  24. 24 v = self._sslobj.read(len, buffer)
  25. 25 socket.timeout: The read operation timed out

 

这种情况可以使用国内的镜像源加速来安装

可以在pip后面添加-i参数,来指定安装源,这里我使用的是阿里云的安装源

  1. 1 [root@localhosts ~]# pip3 install --user matplotlib -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
  2. 2 Collecting matplotlib
  3. 3 Downloading http://mirrors.aliyun.com/pypi/packages/57/4f/dd381ecf6c6ab9bcdaa8ea912e866dedc6e696756156d8ecc087e20817e2/matplotlib-3.1.1-cp36-cp36m-manylinux1_x86_64.whl (13.1MB)
  4. 4 100% |████████████████████████████████| 13.1MB 12.5MB/s
  5. 5 Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
  6. 6 Downloading http://mirrors.aliyun.com/pypi/packages/a3/c4/7828cf9e71ce8fbd43c1e502f3fdd0498f069fcf9d1c268205ce278ae201/pyparsing-2.4.4-py2.py3-none-any.whl (67kB)
  7. 7 100% |████████████████████████████████| 71kB 15.9MB/s
  8. 8 Collecting cycler>=0.10 (from matplotlib)
  9. 9 Downloading http://mirrors.aliyun.com/pypi/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
  10. 10 Collecting numpy>=1.11 (from matplotlib)
  11. 11 Downloading http://mirrors.aliyun.com/pypi/packages/0e/46/ae6773894f7eacf53308086287897ec568eac9768918d913d5b9d366c5db/numpy-1.17.3-cp36-cp36m-manylinux1_x86_64.whl (20.0MB)
  12. 12 100% |████████████████████████████████| 20.0MB 12.1MB/s
  13. 13 Collecting kiwisolver>=1.0.1 (from matplotlib)
  14. 14 Downloading http://mirrors.aliyun.com/pypi/packages/f8/a1/5742b56282449b1c0968197f63eae486eca2c35dcd334bab75ad524e0de1/kiwisolver-1.1.0-cp36-cp36m-manylinux1_x86_64.whl (90kB)
  15. 15 100% |████████████████████████████████| 92kB 15.7MB/s
  16. 16 Collecting python-dateutil>=2.1 (from matplotlib)
  17. 17 Downloading http://mirrors.aliyun.com/pypi/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227kB)
  18. 18 100% |████████████████████████████████| 235kB 12.5MB/s
  19. 19 Requirement already satisfied: six in ./.local/lib/python3.6/site-packages (from cycler>=0.10->matplotlib)
  20. 20 Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages (from kiwisolver>=1.0.1->matplotlib)
  21. 21 Installing collected packages: pyparsing, cycler, numpy, kiwisolver, python-dateutil, matplotlib
  22. 22 Successfully installed cycler-0.10.0 kiwisolver-1.1.0 matplotlib-3.1.1 numpy-1.17.3 pyparsing-2.4.4 python-dateutil-2.8.1

 

 

原文链接:http://www.cnblogs.com/rainights/p/11806723.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号