Wall to put OpenCV 3.1.0 in raspberry pi 3 and run sample on python3: ImportError: No module named cv2 solution

Welcome


environment ・ Raspberry Pi3 Model B

First of all, I am trying to prepare the development environment in order to produce something that the image flows when a person passes in front. As for programming and electronic work, I'm almost a beginner, so the process is awkward, but I've solved one problem, so I'll make a note of it.

Insert openCV to prepare the environment to handle videos


Installation of Raspberry Pi 2 ★ OpenCV 3.1.0 ~ Checking camera operation with C ++ & Python sample This blog post was very easy to understand, so I used it as a reference and did what was written from above. However, since the environment is Raspberry pi3 and python is also version 3, I worked while modifying the directory etc. It takes 3 hours with a sudden freeze on the way.

a problem occured


When I try to run the sample "video.py" after various installations are completed,

No module named cv2


```Occurs. Certainly, I can't find the file cv2 in the "modules" folder inside the opencv folder. (But is that so?)
 I did a file search with cv2 for the time being, but I couldn't find it.

### Measure 1
***

#### Try putting something called pip

[Import Error : No module named cv2 on windows 7](http://stackoverflow.com/questions/40191866/import-error-no-module-named-cv2-on-windows-7)
 I found a person with similar symptoms in this Q & A. The answer says "use pip". pip ...?
 [Pip (Python package management)]
 (http://make.bcde.jp/python/pippython package management /)
 It seems that pip is a library management tool for python, so refer to this page and introduce pip.

 Execute "Package search" in the above article to confirm the existence of cv2. I did "Display list of installed packages" and cv2 was not included in the current list of owned packages, so I tried to download it with "Install by specifying the package name", but it didn't work.

`$ sudo pip install cv2
Collecting cv2
Could not find a version that satisfies the requirement cv2(from versions: )
No matching distribution found for cv2
`

 Continue to look for a solution. ..

### Measure 2
***

#### Put something called python-opencv
 [[python] ImportError: Resolve No module named cv2](http://nc30mtd.oops.jp/blog/2016/07/importerror-no-module-named-cv2.html)
 I found this article.

`$  sudo apt-get install python-opencv
 `Try this command.

 Also,
[Python - cannot import OpenCV module?](http://raspberrypi.stackexchange.com/questions/29148/python-cannot-import-opencv-module)
 In the answer of this forum,
`$  sudo apt-get install libopencv-dev
 `I'll put this in too.

### Solution!
***

 The sample will work safely. Was good!



Recommended Posts

Wall to put OpenCV 3.1.0 in raspberry pi 3 and run sample on python3: ImportError: No module named cv2 solution
How to install OpenCV on Cloud9 and run it in Python
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
What to do if you get Swagger-codegen in python and Import Error: No module named
Run Polyglot on Raspberry Pi to perform morphological analysis in English
Run servomotor on Raspberry Pi 3 using python
ModuleNotFoundError in Python: No module named story
I got an error when I put opencv in python3 with Raspberry Pi [Remedy]
Put MicroPython on Windows to run ESP32 on Python
python> import seiral> ImportError: No module named serial
To add a module to python put in Julialang
Import cv2 ModuleNotFoundError: No module named'cv2' in python3
Sample to put Python Kivy in one file
Connect to MySQL with Python on Raspberry Pi
Install pyenv on Raspberry Pi and version control Python
Output to "7-segment LED" using python on Raspberry Pi 3!
Troubleshoot with installing OpenCV on Raspberry Pi and capturing
Sample of getting module name and class name in Python
If you can't use Beautiful Soup 4 after updating to Python 3.5. ImportError: No module named bs4
Sample to put Python Flask web app on Azure App Service (Web App)
Run BNO055 python sample code with I2C (Raspberry Pi 3B)
Install OpenCV4 on Raspberry Pi 3
Django, nginx, uWSGI, virtualenv ImportError: No module named site Solution Note
How to resolve ModuleNotFoundError: No module named XXX in Jupyter Notebook
Resolved an error when putting pygame in python3 on raspberry pi
Quickly install OpenCV 2.4 (+ python) on OS X and try the sample
I want to run the Python GUI when starting Raspberry Pi
How to use python put in pyenv on macOS with PyCall
Use python on Raspberry Pi 3 to illuminate the LED (Hello World)
How to play music (wav / mp3) files on Raspberry Pi python
[Solved] ImportError: No module named pyexpat and pyenv install is moss
python / netCDF / CentOS 6.8> ImportError: No module named netCDF4> sudo yum install netcdf4-python.x86_64
What to do when ModuleNotFoundError: No module named'XXX' occurs in Python