importerror no module named cv2

Я установил OpenCV в операционной системе Occidentalis (вариант Raspbian) на Raspberry Pi, используя скрипт jayrambhia, найденный здесь. Установлена версия 2.4.5.

Когда я пытаюсь import cv2 в программу Python, я получаю следующее сообщение:

Файл cv2.so хранится в /usr/local/lib/python2.7/site-packages/.

В /usr/local/lib также есть папки с именами python3.2 и python2.6, которые могут быть проблемой, но я не уверен.

Возможно, это ошибка пути? Любая помощь приветствуется, я новичок в Linux.

Сначала выполните эти команды внутри Terminal/CMD:

тогда проблема для инструкции ниже будет решена

для Windows, если у вас установлена Anaconda, вы можете просто сделать

если вы используете Linux, вы можете сделать:

Для python3. 5+ проверьте эти ссылки: Link3, Link4

Это происходит, когда python не может ссылаться на вашу папку пакетов сайтов по умолчанию, в которой вы сохранили требуемые файлы или библиотеки python.

Добавьте эти строки в код:

или перед запуском команды python в bash перейдите в каталог /usr/local/lib/python 2.7/site-packages. Это работа, если вы не хотите добавлять что-либо в код.

Я решил проблему, используя следующую команду:

Попробуйте добавить следующую строку в

Ни один из вышеперечисленных ответов не работал для меня. Я сходил с ума, пока не нашел это решение ниже!

Я решил свою проблему с помощью следующей команды:

Я пришел к тому же, что и эта проблема, я установил cv2 на

Однако, когда я импортирую модуль cv2, он не отображает модуль с именем cv2 error.
Затем я искал и нашел файлы cv2.pyd на своем компьютере, и я cv2.pyd и cv2.pyd в каталог сайтов-пакетов

затем я закрыл и снова открыл существующее приложение, оно сработало.

EDIT Я расскажу, как правильно установить cv2 .

1. Сначала установите numpy на свой компьютер

2. Загрузите opencv из Интернета (почти 266 мб).
Я загружаю opencv-2.4.12.exe для python 2.7. Затем установите этот файл opencv-2.4.12.exe.
Я C:UsersharunDownloads в эту папку.
После установки перейдите в cv2.py
Для меня

в этой папке возьмите cv2.pyd и скопируйте его в

теперь вы можете использовать cv2 в сценариях python.

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):

Содержание

  1. 5 Answers 5
  2. It worked for me, hope the same for you!
  3. Comments
  4. monajalal commented Aug 5, 2016
  5. This comment has been minimized.
  6. mshabunin commented Aug 5, 2016

5 Answers 5

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-pithon in that folder.

Comments

Copy link Quote reply

monajalal commented Aug 5, 2016

This is the make summary:

The only part that differed from tutorial was the following:
-I/usr/include/python3.5m -I/usr/include/python3.5m

I also tried with first not copying and then copying. None worked. If you can help me with this or hint what’s wrong that would really help me.

This comment has been minimized.

Copy link Quote reply

mshabunin commented Aug 5, 2016

This part means that python bindings were not built.

Run the following command:

Then check cmake output for following block (you may need to do a clean build):

After build ( make ), right before installing ( make install ), you can try the library:

I’m marking this issue as invalid, because it looks like a configuration problem. Feel free to add more comments and reopen the issue if you have additional information.

Источник: computermaker.info

Техника и Гаджеты
Добавить комментарий