>>> pip install opencv-python
Collecting opencv-python
Downloading opencv_python-4.5.5.64-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.5 MB)
|▏ | 307 kB 8.7 kB/s eta 1:55:00ERROR: Exception:
Traceback (most recent call last):
File "/home/leezhao/anaconda3/lib/python3.9/site-packages/pip/_vendor/urllib3/response.py", line 438, in _error_catcher
yield
File "/home/leezhao/anaconda3/lib/python3.9/site-packages/pip/_vendor/urllib3/response.py", line 519, in read
data = self._fp.read(amt) if not fp_closed else b""
File "/home/leezhao/anaconda3/lib/python3.9/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "/home/leezhao/anaconda3/lib/python3.9/http/client.py", line 463, in read
n = self.readinto(b)
File "/home/leezhao/anaconda3/lib/python3.9/http/client.py", line 507, in readinto
n = self.fp.readinto(b)
File "/home/leezhao/anaconda3/lib/python3.9/socket.py", line 704, in readinto
return self._sock.recv_into(b)
File "/home/leezhao/anaconda3/lib/python3.9/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/home/leezhao/anaconda3/lib/python3.9/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
使用豆瓣源下载opencv-python
pip install opencv-python -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
或者
pip install opencv-python -i https://pypi.doubanio.com/simple
cv2.error: OpenCV(4.5.5) /io/opencv/modules/highgui/src/window.cpp:1334: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvWaitKey'
或
cv2.error: OpenCV(4.5.5) /io/opencv/modules/highgui/src/window.cpp:651: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
opencv-python需要配套扩展库opencv-contrib-python使用
pip install --upgrade pip
pip install opencv-contrib-python
ImportError: cannot import name '_registerMatType' from 'cv2.cv2'
opencv-python-headless版本过高
pip uninstall opencv-python-headless
pip install "opencv-python-headless<4.3"
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
protobuf 版本过高
pip uninstall protobuf
pip install protobuf==3.20