- ImportError: No module named ‘cv2’ Python3
- 6 Answers 6
- It worked for me, hope the same for you!
- No module named ‘cv2.cv2’
- 5 Answers 5
- Not the answer you’re looking for? Browse other questions tagged python opencv or ask your own question.
- Linked
- Related
- Hot Network Questions
- Subscribe to RSS
- Cannot find module cv2 when using OpenCV
- 19 Answers 19
- ModuleNotFoundError: No module named ‘cv2’
- Решение
- No module named ‘cv2.aruco’
- 1 Answer 1
ImportError: No module named ‘cv2’ Python3
I have such a problem
I don’t have it on python2:
In spite of the fact, that I have opencv (I’ve also tryed to remove it and install then):
6 Answers 6
to get the cv2 . I’m not sure when opencv-python became available. I’d been building opencv by hand, but when I looked a few weeks ago, there it was. I’m using cv2 with Python3 in a VM that’s running ubuntu/trusty64 .
It worked for me
Your conda openCV is installed for use by your home python2.7. Your opencv installed via pip3 is for use in your face_det virtual environment. It doesn’t look like you’re in that virtual environment when you opened python3 in the first code block. Try
I think you’re on Linux judging by pc:
Try installing from the following link:
It worked for me, hope the same for you!
I had a similar problem and the same error. In my case, I was using PyCharm. The problem was that the project’s interpreter was pointing to a different installation of Python.
In my system, I had four versions of python (eg. python3 installed in a python36 folder, another python in an anaconda3 folder and others). In my PyCharm project, when I examined my settings (under File->Settings->Project:xxxx ->Project interpreter), I found that they were pointing to the interpreter in the anaconda3 folder.
However, my default pip installed the opencv-python module under the python36 folder. Therefore, I just had to change the project interpreter to point to the python installed in python36 folder and it worked.
If you would like to keep using Anaconda3 then you have to browse to the anaconda3 folder and run pip install opencv-python in that folder.
No module named ‘cv2.cv2’
I am a beginner at computers. I use Anaconda python 3.6 in windows 10. I have already installed OpenCV using this command:
But when I try to import cv2 using this:
this error shows up:
How can I install openCV for python?
5 Answers 5
Create Virtual Environment
Activate the environment
Install OpenCV and other important packages
Test your installation
Step 1: Uninstall the opencv first if you have previous/other manually installed (= not installed via pip) version of OpenCV installed (e.g. cv2 module in the root of Python’s site-packages)):
Step 2: Install the package afresh
Hope that works!
I had this exact same problem on Windows 10. Uninstalling via pip and then reinstalling in my virtual environment fixed everything up for me.
In my case, using Python 3.8 on Windows 10 and Pycharm (or VS Code as well), I have this same issue.
Finally I noticed that the Antivirus (Nod32) deletes the cv2.cp38-win32.pyd file that should be in the cv2 folder. I simply paused the protection, installed opencv with pip install opencv-python command and it worked just fine.
I hope it helps someone.
I used the answer provided here and it worked.
By running pip install opencv_python-3.4.5-cp36-cp36m-win_amd64.whl
Not the answer you’re looking for? Browse other questions tagged python opencv or ask your own question.
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Cannot find module cv2 when using OpenCV
I have installed OpenCV on the Occidentalis operating system (a variant of Raspbian) on a Raspberry Pi, using jayrambhia’s script found here. It installed version 2.4.5.
When I try import cv2 in a Python program, I get the following message:
The file cv2.so is stored in /usr/local/lib/python2.7/site-packages/.
There are also folders in /usr/local/lib called python3.2 and python2.6, which could be a problem but I’m not sure.
Is this a path error perhaps? Any help is appreciated, I am new to Linux.
19 Answers 19
First do run these commands inside Terminal/CMD:
Then the issue for the instruction below will be resolved
For windows if you have anaconda installed, you can simply do
if you are on linux you can do :
For python3.5+ check these links : Link3 , Link4
Update:
if you use anaconda, you may simply use this as well (and hence don’t need to add menpo channel):
This happens when python cannot refer to your default site-packages folder where you have kept the required python files or libraries
Add these lines in the code:
or before running the python command in bash move to /usr/local/lib/python2.7/site-packages directory. This is a work around if you don’t want to add any thing to the code.
I solved my issue using the following command :
Try to add the following line in
None of the above answers worked for me. I was going crazy until I found this solution below!
For Windows 10 and Python 3.6, this worked for me
pip install opencv-contrib-python
I solved my issue using the following command :
I solve it by running:
or
will definately works fine
I have come accross same as this problem i installed cv2 by
However when i import cv2 module it displayed no module named cv2 error.
Then i searched and find cv2.pyd files in my computer and i copy and paste to site-packages directory
then i closed and reopened existing application, it worked.
EDIT I will tell how to install cv2 correctly.
1. Firstly install numpy on your computer by
2. Download opencv from internet (almost 266 mb).
I download opencv-2.4.12.exe for python 2.7. Then install this opencv-2.4.12.exe file.
I extracted to C:\Users\harun\Downloads to this folder.
After installation go look for cv2.py into the folders.
For me
in this folder take the cv2.pyd and copy it in to the
now you can able to use cv2 in you python scripts.
ModuleNotFoundError: No module named ‘cv2’
ModuleNotFoundError: No module named ‘win32api’
вот такая программка. сначала выскакивала ошибка win32com. установил pywin32. теперь выскакивает.
ModuleNotFoundError: No module named ‘_sqlite3’
Здравствуйте товарищи, пытаюсь запустить одну программу на Python. На Windows запускается хорошо. А.
Ошибка ModuleNotFoundError: No module named ‘matplotlib’
Кто-то может подсказать что сделать? Я просто новичек в Питоне. Буду очень благодарен. import.
При запуске скрипта PyCharm выдаёт «No module named Module»
Здравствуйте, товарищи формучане! Вчера начал изучать великолепный язык под названием Python и.
Покажите что дает вывод этой команды.
P.S. К python ваша проблема отношения не имеет, просто потому что нет такой проблемы.
Ищите свои собственные косяки.
Решение
Installed Pythons found by py Launcher for Windows
-3.7-32 *
-3.7-32
Добавлено через 1 минуту
Запустил скрипт по вашему совету
Тематические курсы и обучение профессиям онлайн Профессия Python-разработчик (Skillbox) Профессия Fullstack-разработчик на Python (Skillbox) Python-разработчик с нуля (Нетология) Fullstack-разработчик на Python (Нетология) |
Заказываю контрольные, курсовые, дипломные и любые другие студенческие работы здесь или здесь.
No module named ‘random’
Здравствуйте! Нужна помощь! С другом хотим создать совместный проект, он на C# я на python.
No module named codecs питон
Всем привет! Скомпилировал значит питон программу в exe. и вроде все получилось, но вылазит такая.
ImportError: No module named ‘codecs’
Всем привет, перевёл я один файл из py в exe выдаёт ошибку ImportError: No module named ‘codecs’ .
Python. ImportError: No module named ‘gdal’
Доброго времени суток! Такая проблема. Стоит Python 3.4.0, скачал gdal с официального сайта.
No module named ‘cv2.aruco’
I have a bit of a problem when trying to use Aruco on Raspberry Pi 3.
I am using Python 3.5 on headless version of Raspbian and I followed this tutorial to install OpenCV with opencv_contrib — which as far as I understand contains all the packages:
OpenCV installed without any problems, I can import it in Python and it works fine. I need to use Aruco for a project and when I try to import it I get this error:
I had the same problem before so I flashed SD card and started with fresh installation, but it happens again. From the previous question I found here I tried to install opencv_contrib by using
But I got the error:
Did anybody encounter the same issue, or do you have any suggestions or how to fix that? Any help would be appreciated.
1 Answer 1
EDIT: I found the perfect solution for the problem with installing additional modules for OpenCV. Previous solution required the manual copying of files from one github directory into another, and copied files had to be added manually into the txt file. This solution allows you to install all the modules without any copying etc. I am leaving my initial thoughts in the answer as they were, the only thing that is changing are the steps to follow. Please correct me if I did anything wrong in regards to editing, as I never had to edit my own answer before due to finding a better solution (as you may see, I’m quite new in here).
I managed to solve my problem and thought I will share my solution as a new answer, so it’s easier for people to see, should anyone encounter the same problem in the future.
The solution works fine when there is only need to install few modules from opencv_contrib as it requires some copying.
New process, after finding better solution:
- Clone both OpenCV and OpenCV_contrib from GitHub
Use cmake command from the tutorial listed above to create installation files for OpenCV. My command looked like this:
cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_C_EXAMPLES=ON \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_EXTRA_MODULES_PATH=
/opencv_contrib/modules \ -D BUILD_EXAMPLES=ON ..
Once this command is completed and you get no errors, run cmake -D OPENCV_EXTRA_MODULES_PATH=
/opencv_contrib/modules .. again
I know it’s simply duplicating a line that was included in cmake before and I have no clue why it works after using this command again. If someone could explain why that happens, I would appreciate it and it would give me some understanding as to why it works. Again, I hope this answer helps anyone who goes through the same problem. Also, I’m sorry for editing this post twice, I thought it will be useful to show people more correct way of sorting this problem out.