Меню Рубрики

Importerror no module named cv2 windows

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.

17 Answers 17

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:

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.

Источник

ImportError: No module named cv2

I’ve been trying to figure this error out for the past day and I’ve looked up error messages all over the internet and still can’t figure out how to get past this error.

I have OpenCV and cv2 setup on my desktop, but I need to program on my laptop now (for mobile reasons). Unfortunately, even though I have OpenCV downloaded, when I try to import cv2, it gives me the error message, «ImportError: No module named cv2».

The closest I’ve gotten so far is «locate cv2» which gives me «/usr/lib/python2.7/dist-packages/cv2.so». I then go into the python shell and run «import sys» then «sys.path.append(‘/usr/lib/python2.7/dist-packages’)» which then gives me a True when I ask «‘/usr/lib/python2.7/dist-packages’ in sys.path». However, when I then try to import cv2, it now returns a new error message of «ImportError: numpy.core.multiarray failed to import». I tried resolving this error, but I had no luck on this either.

I’ve tried everything on forums and message boards online and can’t figure out how to fix this. ANY help would be extremely appreciated, as I need to complete this program by the end of the week.

3 Answers 3

Another reason might be a missing OpenCV module. On my Mac OSX El Capitan [10.11.2 (15C50)], I had the exact same error with Anaconda install, and this resolved the issue:

While that helped deal with:

It also introduced the following issue:

because somehow the numpy version got switched back to 1.7.0. So performing this, worked:

I am currently working with Google VM (ubuntu 14.04). Installing opencv on python3.4 version has been quite a task. I wanted opencv to be installed for python 3.4 but everytime it was getting installed on 2.7 version.

I will share the steps I followed so as to help others on it.

Step 1 Follow all the steps as mentioned on openCv installation part till cmake. Link is given below: https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html

Note: Install all the 3 packages mentioned at start. That optional one too. And dont forget to change the python version for which you are installing.

sudo apt-get install python3-dev python3-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

Follow step 2 for cmake.

Step 2 For installing opencv in specific version of python (ubuntu), you have to set the default (PYTHON_DEFAULT_EXECUTABLE) with the path to where your python is installed. You can find that out by using command whereis python3.4 (or, your version). Mine was in /usr/bin/python3.4

Instead of cmake mentioned on the page, use this,

cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_opencv_python3=ON -D HAVE_opencv_python3=ON -D PYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3.4 ..

Note: Dont forget to change your python version and path in PYTHON_DEFAULT_EXECUTABLE.

Step 3 Follow the remaining steps as mentioned in the link till sudo make install

Источник

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 минуту
Запустил скрипт по вашему совету

Заказываю контрольные, курсовые, дипломные и любые другие студенческие работы здесь.

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 с официального сайта.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Import windows certificate windows 7
  • Import certificate java windows
  • Impact windows and doors
  • Imovie альтернатива для windows
  • Imovie theater для windows