Pycharm не работает cv2

Ошибка установки Pycharm / Python OpenCV и CV2

Я пытался установить как OpenCV, так и cv2 как из Pycharm, так и из терминала, как было предложено использовать:

но я получаю для них следующую ошибку:

Как я могу исправить эти ошибки и правильно установить пакеты? Я использую python 3.4.

5 ответов

Вы получаете эти ошибки, потому что opencv и cv2 не являются именами пакетов python.

Они оба включены как часть пакета opencv-python , доступного для установки из pip.

Если вы используете python 2, вы можете установить с помощью pip:

Или используйте equivilent для python 3:

После запуска соответствующей команды pip ваш пакет должен быть доступен для использования с python.

Я столкнулся с той же проблемой. Одной из проблем может быть создание OpenCV для Python 2.7, а не 3 (не все библиотеки python 2.7 будут работать в python 3 или выше). Я также не считаю, что вы можете загрузить OpenCV напрямую через установщик пакетов PyCharm. Я нашел удачу в соответствии с инструкциями: OpenCV Python. В частности:

  1. Загрузка и установка OpenCV из SourceForge
  2. Копирование файла cv2.pyd из файла загрузки (opencv\build\python\2.7\x64) в папку сайта Python (что-то вроде: C:\Python27\Lib\site-packages)
  3. В PyCharm откройте консоль python (Tools> Python Console) и введите: import cv2 и не допуская ошибок. print cv2.__version__

Кроме того, мне посчастливилось использовать этот пакет opencv-python, который вы можете прямо установить с помощью pip с pip install opencv-python

вот учебник, который работал для меня без каких-либо проблем.

Скопировано с сайта над важной частью:

Скачать версию OpenCV, соответствующую вашей установке Python из здесь. В моем случае Ive использовал opencv_python-3.1.0-cp35-cp35m-win32.whl.

Теперь откройте окно cmd, как раньше. Вы можете открыть его прямо в папке «Загрузка», если вы SHIFT и щелкните правой кнопкой мыши внутри него. Идея состоит в том, чтобы открыть окно cmd, где вы загрузили указанный выше файл [. ]. Используйте команду [. ] для установки [. ] OpenCV:

Примечание: не забудьте изменить имя загруженного файла в используемой вами команде. Очевидно, установив opencv, вы также получите доступ к cv2.

Установка opencv не является прямой. Сначала вам нужно предварительно установить некоторые пакеты.

Я бы не рекомендовал неофициальный пакет opencv-python. Не работает должным образом в macos и ubuntu (см. Этот пост). Не знаю о окнах.

Существует множество веб-страниц, в которых объясняется, как установить opencv и все необходимые пакеты. Например, этот.

Проблема с попыткой установки opencv несколько раз состоит в том, что вам нужно полностью удалить все, прежде чем пытаться снова, или вы можете потерять много ошибок.

Читайте также:  Мегафон модем нет скорости как настроить

Источник

Ошибка установки Pycharm /Python OpenCV и CV2

Я пытался установить как OpenCV, так и cv2 как из Pycharm, так и из терминала, как было предложено, используя:

но я получаю следующую ошибку для них:

Как я могу это исправить и правильно установить пакеты? Я использую Python 3.4.

5 ответов

Вы получаете эти ошибки, потому что opencv и cv2 не являются именами пакетов Python.

Они оба включены как часть пакета opencv-python , доступного для установки из pip.

Если вы используете Python 2, вы можете установить его с помощью pip:

Или используйте эквивалент для Python 3:

После запуска соответствующей команды pip ваш пакет должен быть доступен для использования из python.

Я столкнулся с той же проблемой. Одной из проблем может быть OpenCV, созданный для Python 2.7, а не 3 (не все библиотеки Python 2.7 будут работать в Python 3 или выше). Я также не верю, что вы можете загрузить OpenCV напрямую через установщик пакетов PyCharm. Мне повезло, следуя инструкциям: OpenCV Python . В частности:

  1. Загрузка и установка OpenCV из SourceForge
  2. Копирование файла cv2.pyd из загружаемого файла (opencv \ build \ python \ 2.7 \ x64) в папку site-packages Python (что-то вроде: C: \ Python27 \ Lib \ site-packages)
  3. В PyCharm откройте консоль python (Tools> Python Console) и введите: import cv2 и при условии отсутствия ошибок print cv2.__version__

Кроме того, мне посчастливилось использовать этот пакет opencv-python , который вы можете прямая установка с использованием pip с pip install opencv-python

вот учебник это сработало для меня без проблем.

Скопировано с сайта над важной частью:

Загрузите версию OpenCV, соответствующую вашей установке Python здесь . В моем случае я использовал opencv_python-3,1,0-cp35-cp35m-win32.whl.

Теперь откройте окно cmd, как и раньше. Вы можете открыть это прямо в вашем Папка загрузок, если вы SHIFT и щелкните правой кнопкой мыши внутри нее. Идея открыть окно cmd, в которое вы скачали [. ] указанный выше файл. использование [. ] команда для установки [. ] OpenCV:

Дополнительное примечание: не забудьте изменить имя загруженного файла в команде, которую вы используете. Очевидно, установив opencv, вы получите доступ и к cv2.

Установка opencv не такая прямая. Вы должны предварительно установить некоторые пакеты.

Я бы не рекомендовал неофициальный пакет opencv-python. Не работает должным образом в Macos и Ubuntu (см. Это CMake-когда-установка? noredirect = 1 # comment72858371_42843316″ > пост ). Понятия не имею об окнах.

Существует множество веб-сайтов, объясняющих, как установить opencv и все необходимые пакеты. Например, этот .

Проблема попытки установить opencv несколько раз заключается в том, что вам нужно полностью удалить программу перед повторной попыткой, иначе у вас может возникнуть много ошибок.

Источник

PyCharm does not recognize cv2 as a module

I am using OpenCV 3 and python 2.7 and coding using PyCharm. The code works fine but PyCharm does not recognize cv2 as a module. It underlines it with a red line, so it doesn’t display its functions in the intellisence menu.

Читайте также:  Guitarbackingtrack com не работает

I tried to set an environment variable OPENCV_DIR but it didn’t work

OpenCV is extracted in F:\opencv and Python is installed on C:\Python27

13 Answers 13

here are proper instructions if you have not built opencv from source so that everyone can follow it

  • Click File menu > Settings

  • Search » Project Interpreter » in search bar

Click that + button to install packages or press Alt+Insert

now Available packages window will open and then search for » opencv-python » and click install package button.

Try File->Invalidate Caches / Restart.

I can’t say definitively why this works, but it may have something to do with the cached module definitions that PyCharm uses to provide code hints. In some cases they aren’t updated or get corrupted. I just know that it’s worked for me.

Worked on Pycharm 4.0 version

Follow these steps:

Go to File>Settings in Pycharm IDE Window

Search Project Interpreter in search bar.

  • Click on any package from the available options
  • Package window will open from where you can install any packages.
  • I have installed opencv-python package to run opencv commands

    I’ve solved this problem. Hope this works for you also.

    I have the same problem and I’m afraid that there isn’t a solution for this at the moment. You can read more about the issue here

    The problem is that OpenCV doesn’t include the needed .py file to have the autocomplete which might be why PyCharm isn’t picking up the package as well.

    To be sure that we are on the same page, when you go File>Default Settings>Default Project>Project Interpreter and select the python 2.7 interpreter, does it list cv2 or opencv in the packages?

    EDIT: I was able to get it working with anaconda instead of python. Just instaled anaconda and did everything the same as I would with python (copied cv2 where it would be in python). Hope it helps you!

    Источник

    Pycharm/Python OpenCV and CV2 install error

    I’ve been trying to install both OpenCV and cv2 from both Pycharm and from the terminal as suggested using:

    but I’m getting the following error for them:

    How can I fix these and install the packages properly? I’m using python 3.4.

    20 Answers 20

    You are getting those errors because opencv and cv2 are not the python package names.

    These are both included as part of the opencv-python package available to install from pip.

    If you are using python 2 you can install with pip:

    Or use the equivilent for python 3:

    After running the appropriate pip command your package should be available to use from python.

    This the correct command that you need to install opencv

    if you get any error when you are trying to install the «opencv-python» package in pycharm, make sure that you have added your python path to ‘System Variables‘ section of Environment variables in Windows. And also check whether you have configured a valid interpreter for your project

    Читайте также:  Xiaomi mi5 не работает android pay

    I ran into the same problem. One issue might be OpenCV is created for Python 2.7, not 3 (not all python 2.7 libraries will work in python 3 or greater). I also don’t believe you can download OpenCV directly through PyCharm’s package installer. I have found luck following the instructions: OpenCV Python. Specifically:

    1. Downloading and installing OpenCV from SourceForge
    2. Copying the cv2.pyd file from the download (opencv\build\python\2.7\x64) into Python’s site-packages folder (something like: C:\Python27\Lib\site-packages)
    3. In PyCharm, open the python Console (Tools>Python Console) and type: import cv2 , and assuming no errors print cv2.__version__

    Alternatively, I have had luck using this package opencv-python, which you can straightforwardly install using pip with pip install opencv-python

    will install cv2 in python3.6 branch

    On Windows : !pip install opencv-python

    Try this. I am using Jupyter notebook (OS: Ubuntu 16.04 LTS on Google Cloud Platform + on Windows). Executed following command in the Jupyter notebook to install opencv:

    After successful installation you will get following message:

    Now restart the kernel and try to import opencv as:

    The same command can be used to installed opencv on Windows as well.

    SOLUTION 2: try following commands to install opencv: For Ubuntu: Run following command from terminal:

    Restart Jupyter notebook kernel and execute following command:

    NOTE: You can run all the above commands from the terminal as well without using ‘!’.

    Источник

    Setup OpenCV With PyCharm Environment

    Introduction:

    If you love working on image processing and video analysis using python then you have come to the right place. Python is one of the key languages which is used to process videos and images.

    Requirements for OpenCV:

    • 32- or a 64-bit computer.
    • Windows, macOS or Linux.
    • Python 2.7, 3.4, 3.5 or 3.6.

    PyCharm

    PyCharm is a cross-platform IDE used in computer programming specifically for Python. The platform developed by JetBrains is mainly used in code analysis, graphical debugger etc… It supports web development with Django as well as Data Science with Anaconda.

    Official Website: https://www.jetbrains.com/pycharm/

    OpenCV

    OpenCV (Open Source Computer Vision) is a computer vision library that contains various functions to perform operations on pictures or videos. It was initially built by Intel but later managed by Willow Garag, presently it is managed by Itseez. It is a cross-platform library which available for programming languages apart from python.

    Steps to import OpenCV on PyCharm:

    1) Go to the terminal option at the bottom of the IDE window.

    2) The pip (package manager) can also be used to download and install OpenCV. To install OpenCV, just type the following command:

    Источник

    Оцените статью