欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

VSCode出现ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none)错误

程序员文章站 2023-12-09 20:07:51
1. pip install cv2刚开始因担心下载cv2时,可能因为网络原因,导致时间超出,所以使用pip install --default-timeout=1000 cv2,但是发现出现如下错误:PS F:\py代码> pip install --default-timeout=1000 cv2ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none)ERROR: No...
1. pip install cv2

刚开始因下载cv2时,可能因为网络原因,导致时间超出,所以使用pip install --default-timeout=1000 cv2,但是发现出现如下错误:

PS F:\py代码> pip install --default-timeout=1000 cv2
ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none)
ERROR: No matching distribution found for cv2

然后我又试了下pip install cv2,发现还是出现如下错误:

PS F:\py代码> pip install cv2
ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none)
ERROR: No matching distribution found for cv2
2. pip install opencv-python

然后发现opencv中的cv2在opencv-python包里面,所以可以用pip install opencv-python,但是可能因为网络原因,导致时间超出,可能会出现如下错误:

PS F:\py代码> pip install opencv-python
>>
Collecting opencv-python
  Downloading opencv_python-4.3.0.36-cp38-cp38-win_amd64.whl (33.4 MB)
     || 942 kB 3.3 kB/s eta 2:45:35ERROR: Exception:
Traceback (most recent call last):
  File "f:\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 425, in _error_catcher
    yield
  File "f:\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 507, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "f:\python\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
    data = self.__fp.read(amt)
  File "f:\python\lib\http\client.py", line 454, in read
    n = self.readinto(b)
  File "f:\python\lib\http\client.py", line 498, in readinto
    n = self.fp.readinto(b)
  File "f:\python\lib\socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "f:\python\lib\ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "f:\python\lib\ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "f:\python\lib\site-packages\pip\_internal\cli\base_command.py", line 188, in _main
    status = self.run(options, args)
  File "f:\python\lib\site-packages\pip\_internal\cli\req_command.py", line 185, in wrapper
    return func(self, options, args)
  File "f:\python\lib\site-packages\pip\_internal\commands\install.py", line 332, in run
    requirement_set = resolver.resolve(
  File "f:\python\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 179, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "f:\python\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 362, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "f:\python\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 314, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
  File "f:\python\lib\site-packages\pip\_internal\operations\prepare.py", line 467, in prepare_linked_requirement
    local_file = unpack_url(
  File "f:\python\lib\site-packages\pip\_internal\operations\prepare.py", line 255, in unpack_url
    file = get_http_url(
  File "f:\python\lib\site-packages\pip\_internal\operations\prepare.py", line 129, in get_http_url
    from_path, content_type = _download_http_url(
  File "f:\python\lib\site-packages\pip\_internal\operations\prepare.py", line 281, in _download_http_url
    for chunk in download.chunks:
  File "f:\python\lib\site-packages\pip\_internal\cli\progress_bars.py", line 166, in iter
    for x in it:
  File "f:\python\lib\site-packages\pip\_internal\network\utils.py", line 15, in response_chunks
    for chunk in response.raw.stream(
  File "f:\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 564, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "f:\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 529, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "f:\python\lib\contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "f:\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 430, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
2. pip install --default-timeout=1000 opencv-python

使用pip install --default-timeout=1000 opencv-python,可能会出现错误,错误界面如下:

ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
    opencv-python from https://files.pythonhosted.org/packages/11/d7/5771585ed77ff194d8b7d2e0f32c83af1aafbbdb15357adc8f09dd37dbfa/opencv_python-4.3.0.36-cp38-cp38-win_amd64.whl#sha256=1ea08f22246ccd33174d59edfa3f13930bf2c28096568242090bd9d8770fb8a8:
        Expected sha256 1ea08f22246ccd33174d59edfa3f13930bf2c28096568242090bd9d8770fb8a8
             Got        15a085ffd233b3b04ea4febe3933f737f92deeee6e0fedbccd3fc4a07fd88930

如果不能正确安装可以多安装几次,即可,正确安装界面如下:

PS F:\py代码> pip install --default-timeout=1000 opencv-python
Collecting opencv-python
  Downloading opencv_python-4.3.0.36-cp38-cp38-win_amd64.whl (33.4 MB)
     |████████████████████████████████| 33.4 MB 24 kB/s
Requirement already satisfied: numpy>=1.17.3 in f:\python\lib\site-packages (from opencv-python) (1.18.5)
Installing collected packages: opencv-python
Successfully installed opencv-python-4.3.0.36

本文地址:https://blog.csdn.net/qq_40279192/article/details/107437431