Troubleshoot: "Cannot Find Module cv2" When Using OpenCV
Problem:
After installing OpenCV on a Raspberry Pi running Occidentalis, importing cv2 in a Python program results in an error: "ImportError: No module named cv2."
Solution:
Confirm that the cv2.so file is indeed located in /usr/local/lib/python2.7/site-packages/...
Potential Causes:
Resolution:
For Windows:
Update conda and conda-navigator:
conda update anacoonda-navigator conda update navigator-updater
Install OpenCV with pip:
pip install opencv-python
Alternatively, install OpenCV with conda:
conda install -c https://conda.binstar.org/menpo opencv
For Linux:
Install OpenCV with pip:
pip install opencv-python
Alternatively, install OpenCV with conda:
conda install opencv
For Python 3.5 :
Refer to the links below for additional instructions:
Anaconda Alternative:
If Anaconda is installed, you can also use:
conda install -c conda-forge opencv
The above is the detailed content of Why Can't I Import cv2 in My Python Program After Installing OpenCV?. For more information, please follow other related articles on the PHP Chinese website!