Mac M1 install opencv method and type error resolution

安装opencv:
pip install opencv-python
pip install --user opencv-contrib-python
pip install opencv-python == 4.5.2.54 numpy ==1.25.2

The error reported during the installation process is as follows:
python-type error: "numpy._DTypeMeta" object is not subscriptable
TypeError: 'numpy._DTypeMeta' object is not subscriptable[]

Solution:
The versions of opencv and numpy do not match, and the version needs to be increased or decreased.
Installation environment: python3.9
opencv: 4.5.2.54
numpy: 1.25.2

pip install --upgrade numpy
This command will uninstall the old version of numpy and install the latest version.

Verify that the opencv installation is successful:
import cv2
does not report an error

Supongo que te gusta

Origin blog.csdn.net/Aihu202/article/details/132296826
Recomendado
Clasificación