Pip install opencv python ошибка

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

pip install --user opencv
pip install --user cv2

but I’m getting the following error for them:

Collecting opencv
  Could not find a version that satisfies the requirement opencv (from versions: )
No matching distribution found for opencv

and

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

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

asked Jun 12, 2016 at 15:54

Sibi's user avatar

1

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:

 pip install opencv-python

Or use the equivilent for python 3:

pip3 install opencv-python

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

answered Jan 31, 2018 at 1:40

Ryan Guest's user avatar

Ryan GuestRyan Guest

6,0802 gold badges33 silver badges39 bronze badges

3

This the correct command that you need to install opencv

pip install opencv-python

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

answered Apr 5, 2020 at 6:37

Sankha Rathnayake's user avatar

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

Good luck!

answered Sep 3, 2016 at 15:31

mdoc-2011's user avatar

mdoc-2011mdoc-2011

2,7774 gold badges21 silver badges43 bronze badges

python3.6 -m pip install opencv-python

will install cv2 in python3.6 branch

answered Jun 13, 2018 at 9:47

vishal's user avatar

vishalvishal

8551 gold badge8 silver badges16 bronze badges

0

On Windows:

!pip install opencv-python

Neuron's user avatar

Neuron

5,1615 gold badges38 silver badges59 bronze badges

answered Jun 16, 2020 at 4:24

Knoweldgeyog's user avatar

1

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:

!pip install opencv-contrib-python    #working on both Windows and Ubuntu

After successful installation you will get following message:

Successfully installed opencv-contrib-python-4.1.0.25

Now restart the kernel and try to import opencv as:

import cv2

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:

sudo apt-get install libsm6 libxrender1 libfontconfig1

Restart Jupyter notebook kernel and execute following command:

!pip install opencv-contrib-python

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

answered Jul 26, 2019 at 3:50

Yogesh Awdhut Gadade's user avatar

Keep it simple and just run.

pip install opencv-python

This is the simplest way of installing opencv.
If you still face issue, create a virtual environment and try installing opencv.

Neuron's user avatar

Neuron

5,1615 gold badges38 silver badges59 bronze badges

answered Sep 15, 2021 at 15:23

Ranjeet R Patil's user avatar

2

here is a tutorial that worked for me without any problem.

Copied from the site above the important part:

Download the OpenCV version corresponding to your Python installation
from here. In my case, I’ve used
opencv_python-3.1.0-cp35-cp35m-win32.whl.

Now, open a cmd window like before. You can open this directly in your
Downloads folder if you SHIFT and right click inside it. The idea is
to open a cmd window where you’ve downloaded the above […] file. Use
the […] command to install […] OpenCV:

1     pip install "opencv_python-3.1.0-cp35-cp35m-win32.whl"

Additional note: don’t forget to change the name of the downloaded file in the command you use.
Apparently by installing opencv, you’ll have access to cv2 too.

answered Dec 20, 2016 at 12:08

Judit's user avatar

JuditJudit

392 bronze badges

Installing opencv is not that direct.
You need to pre-install some packages first.

I would not recommend the unofficial package opencv-python. Does not work properly in macos and ubuntu (see this post). No idea about windows.

There are many webs explaining how to install opencv and all required packages.
For example this one.

The problem of trying to install opencv several times is that you need to uninstall completely before attempting again, or you might end having many errors.

Community's user avatar

answered Apr 11, 2017 at 14:46

daniel_hck's user avatar

daniel_hckdaniel_hck

1,1003 gold badges19 silver badges38 bronze badges

you must install opencv-python
pip/pip3 install opencv-python
if you try import opencv-python, receive error.
Fix this error, use the import cv2

answered May 12, 2019 at 11:12

yunusemredemirbas's user avatar

How about try some different mirrors?
If you are in China, I highly recommend you try:

sudo pip install --index https://pypi.mirrors.ustc.edu.cn/simple/ opencv-contrib-python

If not, just replace the url address to some other mirrors you like!
Good luck.

answered Jul 24, 2019 at 6:04

plotseeker's user avatar

First step:

pip uninstall numpy
pip uninstall opencv-python

Second step:

pip install numpy
pip install opencv-python

answered Feb 7, 2021 at 7:25

Furkan Gulsen's user avatar

Furkan GulsenFurkan Gulsen

1,3842 gold badges12 silver badges24 bronze badges

If you still find any error to install open-cv in your mac, try this:

opencv-python==4.2.0.34

This worked for me.

answered May 2, 2022 at 22:28

Dipanwita Mallick's user avatar

I had the same problem. Here are the steps for Windows 10 users.

Open CMD: win+r then type cmd. Now,

  1. Type pip install virtualenv
  2. Create a Virtual Environment, Type virtualenv testopencv
  3. Get Inside testopencv, Type cd testopencv
  4. Activate the Virtual Environment, Type .\Scripts\activate
  5. Now Install Opencv, Type pip install opencv-contrib-python --upgrade
  6. Let’s test Opencv, Type Python then import cv2 hit enter then type print(cv2.__version__) to check if its installed

Now, open a new cmd, win + r then type cmd, repeat step 6. If it gives you an error.

Go inside the testopencv folder, inside lib. Copy everything, go to your python directory, inside lib folder paste it and skip that are already present.

Again open a new cmd, repeat Step 6.

Hope it helps.

answered Jan 7, 2020 at 7:37

Debu Shinobi's user avatar

Debu ShinobiDebu Shinobi

2,06118 silver badges21 bronze badges

In jetso nano this work for me.

$ git clone https://github.com/JetsonHacksNano/buildOpenCV
$ cd buildOpenCV

4b0's user avatar

4b0

22k30 gold badges95 silver badges142 bronze badges

answered Mar 30, 2020 at 11:42

Sirosh Bashir's user avatar

When I was facing this issue I used to install OpenCV in pycharm installed package panel where we can find under the settings tab. Search «OpenCV-python» and install it in the installed package panel of right interpreter.

answered May 8, 2020 at 15:18

Hashan Malawana's user avatar

Hashan MalawanaHashan Malawana

3531 gold badge2 silver badges10 bronze badges

First run from cmd

pip --version

to make sure that you have the updated version installed.

Then run

pip install opencv-python

answered Jun 29, 2021 at 5:13

NAVNEET CHANDAN's user avatar

Go through with this link: https://learnopencv.com/install-opencv-4-on-raspberry-pi/

you can install OpenCV perfectly with out any error. but the problem was it will take lot of time to install.

I had used pi3 model B+ with 32GB class10 SD card for me it took more than 12 hours for complete installation.

answered Jul 25, 2021 at 7:01

yoganandham pachigari's user avatar

Solution 1:[1]

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:

 pip install opencv-python

Or use the equivilent for python 3:

pip3 install opencv-python

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

Solution 2:[2]

This the correct command that you need to install opencv

pip install opencv-python

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

Solution 3:[3]

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

Good luck!

Solution 4:[4]

python3.6 -m pip install opencv-python

will install cv2 in python3.6 branch

Solution 5:[5]

On Windows :
!pip install opencv-python

Solution 6:[6]

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:

!pip install opencv-contrib-python    #working on both Windows and Ubuntu

After successful installation you will get following message:

Successfully installed opencv-contrib-python-4.1.0.25

Now restart the kernel and try to import opencv as:

import cv2

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:

sudo apt-get install libsm6 libxrender1 libfontconfig1

Restart Jupyter notebook kernel and execute following command:

!pip install opencv-contrib-python

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

Solution 7:[7]

Solution 8:[8]

Keep it simple and just run.

sudo pip install opencv-python

This is the simplest way of installing opencv.
If you still face issue, create a virtual environment and try installing opencv.

Solution 9:[9]

here is a tutorial that worked for me without any problem.

Copied from the site above the important part:

Download the OpenCV version corresponding to your Python installation
from here. In my case, I’ve used
opencv_python-3.1.0-cp35-cp35m-win32.whl.

Now, open a cmd window like before. You can open this directly in your
Downloads folder if you SHIFT and right click inside it. The idea is
to open a cmd window where you’ve downloaded the above […] file. Use
the […] command to install […] OpenCV:

1     pip install "opencv_python-3.1.0-cp35-cp35m-win32.whl"

Additional note: don’t forget to change the name of the downloaded file in the command you use.
Apparently by installing opencv, you’ll have access to cv2 too.

Solution 10:[10]

Installing opencv is not that direct.
You need to pre-install some packages first.

I would not recommend the unofficial package opencv-python. Does not work properly in macos and ubuntu (see this post). No idea about windows.

There are many webs explaining how to install opencv and all required packages.
For example this one.

The problem of trying to install opencv several times is that you need to uninstall completely before attempting again, or you might end having many errors.

Solution 11:[11]

you must install opencv-python
pip/pip3 install opencv-python
if you try import opencv-python, receive error.
Fix this error, use the import cv2

Solution 12:[12]

How about try some different mirrors?
If you are in China, I highly recommend you try:

sudo pip install --index https://pypi.mirrors.ustc.edu.cn/simple/ opencv-contrib-python

If not, just replace the url address to some other mirrors you like!
Good luck.

Solution 13:[13]

Solution 14:[14]

I had the same problem. Here are the steps for Windows 10 users.

Open CMD: win+r then type cmd. Now,

  1. Type pip install virtualenv
  2. Create a Virtual Environment, Type virtualenv testopencv
  3. Get Inside testopencv, Type cd testopencv
  4. Activate the Virtual Environment, Type .\Scripts\activate
  5. Now Install Opencv, Type pip install opencv-contrib-python --upgrade
  6. Let’s test Opencv, Type Python then import cv2 hit enter then type print(cv2.__version__) to check if its installed

Now, open a new cmd, win + r then type cmd, repeat step 6. If it gives you an error.

Go inside the testopencv folder, inside lib. Copy everything, go to your python directory, inside lib folder paste it and skip that are already present.

Again open a new cmd, repeat Step 6.

Hope it helps.

Solution 15:[15]

Solution 16:[16]

In jetso nano this work for me.

$ git clone https://github.com/JetsonHacksNano/buildOpenCV
$ cd buildOpenCV

Solution 17:[17]

When I was facing this issue I used to install OpenCV in pycharm installed package panel where we can find under the settings tab. Search «OpenCV-python» and install it in the installed package panel of right interpreter.

Solution 18:[18]

First step:

pip uninstall numpy
pip uninstall opencv-python

Second step:

pip install numpy
pip install opencv-python

Solution 19:[19]

First run from cmd

pip --version

to make sure that you have the updated version installed.

Then run

pip install opencv-python

Solution 20:[20]

Go through with this link: https://learnopencv.com/install-opencv-4-on-raspberry-pi/

you can install OpenCV perfectly with out any error. but the problem was it will take lot of time to install.

I had used pi3 model B+ with 32GB class10 SD card for me it took more than 12 hours for complete installation.

Solution 21:[21]

If you still find any error to install open-cv in your mac, try this:

opencv-python==4.2.0.34

This worked for me.

[('cp36', 'cp36m', 'linux_x86_64'), ('cp36', 'abi3', 'linux_x86_64'), ('cp36', 'none', 'linux_x86_64'), ('cp35', 'abi3', 'linux_x86_64'), ('cp34', 'abi3', 'linux_x86_64'), ('cp33', 'abi3', 'linux_x86_64'), ('cp32', 'abi3', 'linux_x86_64'), ('py3', 'none', 'linux_x86_64'), ('cp36', 'none', 'any'), ('cp3', 'none', 'any'), ('py36', 'none', 'any'), ('py3', 'none', 'any'), ('py35', 'none', 'any'), ('py34', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')] is what I get by checking the supported tags. I thought manylinux would work because I thought I had used them before, but I just checked the PyTorch wheel I had used and it is actually linux_x86_64, so my mistake. I guess CentOS is not compatible with manylinux. If I cannot use the manylinux wheels, and I cannot use pip as it cannot find opencv-python, am I just not able to use opencv-python? I don’t think there was a linux_x86_64 wheel available.

OpenCV

Loading

0 / 0 / 0

Регистрация: 20.10.2018

Сообщений: 10

1

20.10.2018, 17:31. Показов 20420. Ответов 16


Студворк — интернет-сервис помощи студентам

Доброго дня!
Винда7 х64 питон37-32, опен св ставится, но при подключении (import cv2) выдает ошибку: не найден путь к модулю. в чем может быть проблема. Опенсв поставил с помощью инструкции pip
Указанные советы в Установка OpenCV на python 3.4 все поюзал уже
Сообщение об ошибке:

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type «copyright», «credits» or «license()» for more information.
>>>
============== RESTART: C:\Program Files (x86)\Python37-32\1.py ==============
Traceback (most recent call last):
File «C:\Program Files (x86)\Python37-32\1.py», line 1, in <module>
import cv2
ImportError: DLL load failed: Не найден указанный модуль.



0



Programming

Эксперт

94731 / 64177 / 26122

Регистрация: 12.04.2006

Сообщений: 116,782

20.10.2018, 17:31

16

1291 / 908 / 479

Регистрация: 05.12.2013

Сообщений: 3,073

20.10.2018, 23:50

2

Вы в IDLE запускаете, возьмите нормальный редактор



0



0 / 0 / 0

Регистрация: 20.10.2018

Сообщений: 10

21.10.2018, 20:11

 [ТС]

3

Это понятно, писать код можно хоть в блокноте, а исполнять код как тогда? не редактором ведь.. или я чего то не знаю?



0



Garry Galler

Эксперт Python

5412 / 3836 / 1214

Регистрация: 28.10.2013

Сообщений: 9,554

Записей в блоге: 1

22.10.2018, 00:17

4

Наберите в консоли cmd команду:

Windows Batch file
1
pip3.7 show opencv-python

Примерный вывод, если библиотека установлена:

Код

Name: opencv-python
Version: 3.4.3.18
Summary: Wrapper package for OpenCV python bindings.
Home-page: https://github.com/skvark/opencv-python
Author: None
Author-email: None
License: MIT
Location: d:\install\python37-32\lib\site-packages
Requires: numpy
Required-by:

Если нет — очевидно, что вы неверно(не в тот python — если их несколько, то легко ошибиться) установили.
Только что вот сам промахнулся и не в ту установку 3.7 установил его (у меня еще embedded версия в PATH).
Поэтому советую пользоваться командами установки через py.

Код

py -3.7 -m pip модуль

чтобы работал pip из той установки python, которая требуется.
Переустановил другой командой. Итог:

Код

D:\INSTALL\Python37-32>py -3.7
Python 3.7.0b3 (v3.7.0b3:4e7efa9c6f, Mar 29 2018, 17:46:48) [MSC v.1913 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.4.3'
>>>

P.S. Хотя, может быть у вас opencv_ffmpeg343.dll не установилась?



0



0 / 0 / 0

Регистрация: 20.10.2018

Сообщений: 10

23.10.2018, 09:01

 [ТС]

5

Добрый день. Судя по выданному листингу, библиотека встала как надо, все совпадает строчка в строчку. Что делать если да? а библиотека не импортируется

Миниатюры

Не импортируется opencv в питоне
 



0



1291 / 908 / 479

Регистрация: 05.12.2013

Сообщений: 3,073

23.10.2018, 09:40

6

Наберите в командной строке
py -3.7
и затем

import cv2



0



0 / 0 / 0

Регистрация: 20.10.2018

Сообщений: 10

23.10.2018, 12:52

 [ТС]

7

py -3.7 — такой команды не существует

Миниатюры

Не импортируется opencv в питоне
 



0



1291 / 908 / 479

Регистрация: 05.12.2013

Сообщений: 3,073

23.10.2018, 13:20

8

тогда так

python

и затем

import cv2



0



0 / 0 / 0

Регистрация: 20.10.2018

Сообщений: 10

23.10.2018, 18:58

 [ТС]

9

Такая же ошибка.

Миниатюры

Не импортируется opencv в питоне
 



0



Эксперт Python

5412 / 3836 / 1214

Регистрация: 28.10.2013

Сообщений: 9,554

Записей в блоге: 1

23.10.2018, 19:13

10

Проверьте наличие opencv_ffmpeg343.dll в директории lib\site-packages\cv2



0



0 / 0 / 0

Регистрация: 20.10.2018

Сообщений: 10

23.10.2018, 19:17

 [ТС]

11

библиотека на месте

Миниатюры

Не импортируется opencv в питоне
 



0



Эксперт Python

5412 / 3836 / 1214

Регистрация: 28.10.2013

Сообщений: 9,554

Записей в блоге: 1

23.10.2018, 19:24

12

Ну тут сказать нечего — не иначе как барабашка виноват :-)
Если серьезно, то попробовать переустановить, потому что каких-то явных причин для этой ошибки нет, а вот про неявные на чужом компе ничего не скажешь.



0



0 / 0 / 0

Регистрация: 20.10.2018

Сообщений: 10

23.10.2018, 19:31

 [ТС]

13

Да пробовал уже переустанавливать, и 64-битный ставил, и версию ниже, на 8 или 10 винде ребята проверяли все нормально ставится, но из-за этого не хочется ломать нормально работающую систему к которой уже привык. Может в реестре установщик где что какие пути прописывает…



0



Эксперт Python

5412 / 3836 / 1214

Регистрация: 28.10.2013

Сообщений: 9,554

Записей в блоге: 1

24.10.2018, 15:41

14

Цитата
Сообщение от EduardShD
Посмотреть сообщение

Может в реестре установщик где что какие пути прописывает.

pip не делает в реестре никаких записей. По сути whl архив, который качает pip, это просто zip файл — можно все распаковать и установить вручную.
Если проблема в вашей ОС, то мы вам ничем не можем помочь.



0



0 / 0 / 0

Регистрация: 20.10.2018

Сообщений: 10

24.10.2018, 18:45

 [ТС]

15

Ставил то же самое на 7 компов, там тоже винда7 и тот же баг, проблема может быть и в винде, но ошибка связана (DLL load failed: Не найден указанный модуль. ) с загрузкой dll -ки. В ошибке ссылка на 3 строку файла __init__.py из директории ..\cv2\

from .cv2 import *

если открыто это файл и исполнить вылазит ошибка:
Traceback (most recent call last):
File «C:\Program Files (x86)\Python37-32\Lib\site-packages\cv2\__init__.py», line 3, in <module>
from .cv2 import *
ModuleNotFoundError: No module named ‘__main__.cv2’; ‘__main__’ is not a package

Неужели винда 7 состарилась и opencv в принципе там терь не работает. Но ведь на одному ноуте работает, там раньше был питон2.7, я его деинсталлировал и поставил то же 3.7. все так же. Вопрос что не так?



0



Эксперт Python

5412 / 3836 / 1214

Регистрация: 28.10.2013

Сообщений: 9,554

Записей в блоге: 1

24.10.2018, 19:46

16

Цитата
Сообщение от EduardShD
Посмотреть сообщение

Неужели винда 7 состарилась и opencv в принципе там терь не работает

Я вам показывал пример своей установки именно на win 7 (но, правда, x32 разрядности).

Цитата
Сообщение от EduardShD
Посмотреть сообщение

если открыто это файл и исполнить вылазит ошибка:

Не надо это делать. Ошибка No module named ‘__main__ обычная и говорит, о том что человек ее вызвавший не разбирается в системе импорта python.



0



0 / 0 / 0

Регистрация: 20.10.2018

Сообщений: 10

09.12.2018, 19:09

 [ТС]

17

Всем привет! Я все таки решил для себя проблему с ошибкой dll в винде 7. Может кому пригодится. Пока только с версией python 2.7.x
1. Ставим питон. Качаем отсюда https://www.python.org/ftp/pyt… 2.7.10.msi
2. Ставим numpy и opencv c помощью pip install numpy и pip install opencv-python
3. Качаем open cv отсюда http://sourceforge.net/project… e/download (также проверялась версия 3.2.0) и распакуем в любую папку.
4. Копируем cv2.pyd из распакованного отсюда \opencv\build\python\cv2\python-2.7
5. Копируем в папку с установленным питоном поверх \Python27\Lib\site-packages\cv2

Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type «copyright», «credits» or «license()» for more information.
>>> import cv2
>>> print cv2.__version__
3.2.0
>>>

Не знаю почему работает. С 3 версией питона разбираюсь. Всем кто помогал спасибо. И я действительно не разбираюсь в системе импорта питон.

p.s. Винда 64х, установлены все обновления и библиотеки vc_redist.x64.exe и vc_redist.x86.exe



0



Понравилась статья? Поделить с друзьями:

Интересное по теме:

  • Pip install numpy ошибка
  • Pixma mg2240 сброс ошибок
  • Pip install mysqlclient ошибка
  • Pixma g2400 ошибка 5200
  • Pip install mysql python ошибки

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии