Python pip安装镜像失败 opencv-python 已解决

下载镜像翻墙速度慢导致安装失败:

问题:安装opencv-python失败

root@23c943ed55e4:/workspace# pip install opencv-python
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting opencv-python
  Downloading https://files.pythonhosted.org/packages/77/30/36c3f0644fa9f42d92f079b972e990a5874c1fc2b2c0e9656eb88bb8d6dc/opencv_python-4.1.0.25-cp27-cp27mu-manylinux1_x86_64.whl (26.6MB)
     |                                | 358kB 9.5kB/s eta 0:45:56ERROR: Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cli/base_command.py", line 178, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/commands/install.py", line 352, in run
    resolver.resolve(requirement_set)
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/resolve.py", line 131, in resolve
    self._resolve_one(requirement_set, req)
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/resolve.py", line 294, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/resolve.py", line 242, in _get_abstract_dist_for
    self.require_hashes
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/operations/prepare.py", line 347, in prepare_linked_requirement
    progress_bar=self.progress_bar
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/download.py", line 886, in unpack_url
    progress_bar=progress_bar
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/download.py", line 746, in unpack_http_url
    progress_bar)
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/download.py", line 954, in _download_http_url
    _download_url(resp, link, content_file, hashes, progress_bar)
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/download.py", line 683, in _download_url
    hashes.check_against_chunks(downloaded_chunks)
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/utils/hashes.py", line 62, in check_against_chunks
    for chunk in chunks:
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/download.py", line 651, in written_chunks
    for chunk in chunks:
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/utils/ui.py", line 156, in iter
    for x in it:
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/download.py", line 640, in resp_read
    decode_content=False):
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/response.py", line 494, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/response.py", line 459, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/response.py", line 374, in _error_catcher
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

解决方法:使用国内镜像下载python库opencv-contrib-python

root@23c943ed55e4:/workspace# pip install --index https://pypi.mirrors.ustc.edu.cn/simple/ opencv-python==3.1.0.3
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Looking in indexes: https://pypi.mirrors.ustc.edu.cn/simple/
Collecting opencv-contrib-python
  Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/b6/ed/534f97af6a8940da5f4076b530f07d1d660ba1aeb25dade588f96b065af5/opencv_contrib_python-4.1.0.25-cp27-cp27mu-manylinux1_x86_64.whl (32.6MB)
     |################################| 32.6MB 3.2MB/s
Requirement already satisfied: numpy>=1.11.1 in /usr/local/lib/python2.7/dist-packages (from opencv-python==3.1.0.3) (1.14.2)
Installing collected packages: opencv-contrib-python
Successfully installed opencv-contrib-python-3.1.0.3

查看cv2是否安装成功:没有报错说明cv2安装成功

root@23c943ed55e4:/workspace# python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> 

如想使用国内镜像下载其他库pkgsName

 pip install --index https://pypi.mirrors.ustc.edu.cn/simple/ pkgsName

 

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值