Error no matching distribution found for cv2

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 fo...

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

5,9102 gold badges32 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 (opencvbuildpython2.7×64) into Python’s site-packages folder (something like: C:Python27Libsite-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,5874 gold badges20 silver badges42 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

7857 silver badges16 bronze badges

0

On Windows:

!pip install opencv-python

Neuron's user avatar

Neuron

4,8535 gold badges36 silver badges54 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

4,8535 gold badges36 silver badges54 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,0602 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,2442 gold badges10 silver badges22 bronze badges

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 .Scriptsactivate
  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

1,79816 silver badges20 bronze badges

In jetso nano this work for me.

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

4b0's user avatar

4b0

21.4k30 gold badges95 silver badges139 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

3431 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

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’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

5,9102 gold badges32 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 (opencvbuildpython2.7×64) into Python’s site-packages folder (something like: C:Python27Libsite-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,5874 gold badges20 silver badges42 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

7857 silver badges16 bronze badges

0

On Windows:

!pip install opencv-python

Neuron's user avatar

Neuron

4,8535 gold badges36 silver badges54 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

4,8535 gold badges36 silver badges54 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,0602 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,2442 gold badges10 silver badges22 bronze badges

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 .Scriptsactivate
  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

1,79816 silver badges20 bronze badges

In jetso nano this work for me.

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

4b0's user avatar

4b0

21.4k30 gold badges95 silver badges139 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

3431 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

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

Today We are Going To Solve Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2 in Python. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.

  1. How to Fix Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2 Error?

    To Fix Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2 Error just Install opencv. Here you have to install opencv If you are using python 2 then you can install it with pip: pip install opencv-python And if you are using python 3 then use the equivalent pip3 install opencv-python

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

    To Fix Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2 Error just Use the below command. Use this command to solve this error pip install numpy pip install opencv-python

Solution 1 : Install opencv

Here you have to install opencv

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

 pip install opencv-python

And if you are using python 3 then use the equivalent

pip3 install opencv-python

Solution 2 : Use the below command

Use this command to solve this error

pip install numpy
pip install opencv-python

Conclusion

So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.

Also Read These Solutions

  • An unhandled exception occurred: NOT SUPPORTED: keyword “id”, use “$id” for schema ID
  • Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)
  • Notice: Trying to access array offset on value of type bool
  • xlrd.biffh.XLRDError: Excel xlsx file; not supported in python
  • ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()

Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to install cv2 with this command pip install –user cv2 but I am facing following error Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2 in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

Contents

  1. How Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2 Error Occurs ?
  2. How To Solve Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2 Error ?
  3. Solution 1: install opencv-python
  4. Solution 2: Use correct python command
  5. Summary

I am trying to install cv2 with this command pip install –user cv2 but I am facing following error.

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

How To Solve Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2 Error ?

  1. How To Solve Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2 Error ?

    To Solve Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2 Error You are facing this error because of you are opencv and cv2 are not the python package names Actually Both packages included as part of the opencv-python package available to install from pip Just install opencv-python with this command. For Python 2: pip install opencv-python and For Python 3: pip3 install opencv-python Now your error must be solved and now you can use opencv and cv2.

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

    To Solve Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2 Error You are facing this error because of you are opencv and cv2 are not the python package names Actually Both packages included as part of the opencv-python package available to install from pip Just install opencv-python with this command. For Python 2: pip install opencv-python and For Python 3: pip3 install opencv-python Now your error must be solved and now you can use opencv and cv2.

Solution 1: install opencv-python

You are facing this error because of you are opencv and cv2 are not the python package names Actually Both packages included as part of the opencv-python package available to install from pip Just install opencv-python with this command.

For Python 2

 pip install opencv-python

For Python 3

pip3 install opencv-python

Now your error must be solved and now you can use opencv and cv2.

Solution 2: Use correct python command

You are using wrong python command. Just use this command.

pip install opencv-python

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

  • SyntaxError: invalid syntax to repo init in the AOSP code.

If you are getting trouble with the “Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2” error, do not worry. Today, our article will give a few solutions and detailed explanations to handle the problem. Keep on reading to get your answer.

First, you should be clear that OpenCV (Open Source Computer Vision Library) is an open-source machine learning software library, mainly computer vision. Cv2 is the module import name which represents the ‘opencv-python’ package. 

This error occurs because you have some misunderstandings when installing the package. You must have installed the ‘opencv-python’ package instead of installing cv2. This is an example about the error:

pip install cv2

Result:

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

Keep going on. Now, we provide you with a few ways to install ‘opencv-python’ package.

Solutions to solve this problem

Install OpenCV by using pip

Pip is a package manager used to control other packages in python. 

First, make sure that your system has installed pip. If not, please visit here. In this tutorial, we only focus on installing the ‘opencv-python’ package. 

Install the package by pip in Windows Operating System or Terminal with Linux Operating System or macOS, run the following command:

For the main module package:

pip install opencv-python

For full package:

pip install opencv-contrib-python

Install the package for server or no GUI library system:

For the main module package:

pip install opencv-python-headless

For full package:

pip install opencv-contrib-python-headless

Install OpenCV from GitHub 

In Windows Operating System

Follow these steps

  • Step 1: Download the latest.
  • Step 2: Unzip to C:opencv.
  • Step 3: Add the Path in Environment Variables setting to C:opencvbin.
  • Step 4: Reset your computer
  • Step 5: Run the command echo %Path% in your Command Prompt. If there is the Path to C:opencvbin, you installed it successfully.

In Linux Operating System

Step 1: Install essential packages

sudo apt update && sudo apt install -y cmake g++ wget unzip

Step 2: Download and unzip sources

wget -O opencv.zip https://github.com/opencv/opencv/archive/4.x.zip
unzip opencv.zip

Step 3: Create a directory to build the sources

mkdir -p build && cd build

Step 4: Make configuration

cmake ../opencv-4.x

Step 5: Build modules

cmake --build 

Source: opencv.org

Summary

Our article has explained the cause of the “Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2” error. We also give you instructions to install OpenCV as a user and developer. Hope you our tutorial helps you to fix the problem completely. Thanks for reading!

Maybe you are interested:

  • IsADirectoryError: [Errno 21] Is a directory in Python
  • ‘pyinstaller’ is not recognized as an internal or external command operable program or batch file

My name is Robert Collier. I graduated in IT at HUST university. My interest is learning programming languages; my strengths are Python, C, C++, and Machine Learning/Deep Learning/NLP. I will share all the knowledge I have through my articles. Hope you like them.

Name of the university: HUST
Major: IT
Programming Languages: Python, C, C++, Machine Learning/Deep Learning/NLP

@another-guy

Hello Olli-Pekka,

First of all I must say thank you for starting this repository. I am very new to both Python and OpenCV.
I’m trying to start a new project that will intensively use OpenCV. Could you please clarify whether it is possible or not to have a complete OpenCV installation entirely based on pip or easy_install packages? If yes, than what are the steps I should follow.

Drawing a parallel with .NET/Java, I’d like to introduce a single dependency on NuGet/Maven package of OpenCV. In my scenario, development is going to be all in Python, though.

I understand, this question does not really belong here but I can’t find a better place and more knowledgeable person to get it answered.

Thanks!

@skvark

Do you mean by «complete installation» the Python bindings?

Currently there is no pre-built packages for the OpenCV Python bindings on PyPI (=Python package index), but the aim of this repository is to provide them when we get all the builds stable (Linux and Windows are just about ready, but OS X needs more work). I have been very busy lately, but I’m going to focus more on this during next week so the packages should be available on PyPI soon.

In practice this means that when we are ready to push all of these wheels (=python’s pre-built packages) to PyPI, one could simply install the OpenCV package with following command:

pip install opencv-python

and use it with the following import statement:

import cv2

If your project is simple, then you could just add the opencv-python dependency to your setup.py file. However, I recommend to use requirements.txt file for defining the dependencies if your project depends on many packages.

If you’re using Windows, you can already install the opencv-python package manually by downloading a package from Appveyor https://ci.appveyor.com/project/skvark/opencv-python/build/artifacts and installing it with pip:

pip install name_of_the_wheel_file.whl

@another-guy

Do you mean by «complete installation» the Python bindings?

I feel very badly about not being able to formulate my question properly due to lack of Python terminology knowledge. Basically, I mean, I’m looking for a «ready to go» Python package that I can refer in my project. I expect this to result in my code downloading OpenCV as a dependency regardless of the platform it runs on, i.e. platform specific binaries.
Again, I don’t even know whether it is achievable because I don’t know much about packaging in Python world.

pip install opencv-python

This seems to be the way to go but it won’t work in windows for me:

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

If you’re using Windows, you can already install the opencv-python package manually by downloading a package from Appveyor

Manual installation is exactly what I am trying to avoid. :)

Offtopic: I’d really appreciate you pointing me to documents that explain Python packaging so that I’m not asking stupid questions in stupid forms anymore. 😞

@skvark

I feel very badly about not being able to formulate my question properly due to lack of Python terminology knowledge. Basically, I mean, I’m looking for a «ready to go» Python package that I can refer in my project. I expect this to result in my code downloading OpenCV as a dependency regardless of the platform it runs on, i.e. platform specific binaries.
Again, I don’t even know whether it is achievable because I don’t know much about packaging in Python world.

It’s not a problem :) Python’s packaging is currently a bit complicated: there are many ways to do it, but most of them are legacy. You can read more about the packaging from here: https://packaging.python.org/

In brief, this repository is simply just a bunch of automated build scripts (meant to be run on CI systems like Travis and Appveyor) which will compile OpenCV and embed it to a python wheel package. During the compilation the C++ code is wrapped in a special python compatible way (http://docs.opencv.org/3.1.0/da/d49/tutorial_py_bindings_basics.html#gsc.tab=0). The end result is shared library which is then copied to the actual Python package and can be imported with python.

This process is repeated multiple times for every platform (this is not a so called universal package due to an binary extension) and all the results will be uploaded to PyPI (in the future). For example, you can have a look at numpy and observe the many different .whl files for different platforms: https://pypi.python.org/pypi/numpy

pip install will then select the correct package from all the listed packages according to the platform on which it was run. In this case manual installation is needed before we start uploading opencv-python wheels to PyPI. And for the record, these «wheels» are just zip files :)

@another-guy

@skvark Thanks! Your intro is helpful! I don’t think there’s need in keeping this issue open. (btw, windows installation of wheel did actually work for me).

Olli-Pekka, is there a way for me to contact you directly regarding OpenCV or Python? I have 10 years of experience with .NET/Java and would love to be able to ramp up with Python quickly. Considering the style and structure of your explanatory messages, I believe you can be very helpful as a mentor for me. So, if you have time and are willing to I’d write you questions time to time. Let me know.

@skvark

You can contact me for example via Twitter, I’ll share my email address privately.

@spencerahill

Sorry if this should be painfully obvious already, but I am still in need of clarification. Let’s suppose I am on a machine on which openCV has not been installed. Will pip install opencv-python install opencv itself as well as the python bindings that are accessible within python via import cv2? Or does openCV itself need to be installed separately? Thanks.

@skvark

@spencerahill

@skvark thanks, that helps a lot. So, in other words, as long as the user only needs to interact with opencv through python, then pip install opencv-python gets them everything they need.

Given that the full opencv build is not trivial, that’s a nice accomplishment!

@skvark

Yes, that’s correct. Please note that #14 and #17 may block some use cases (stuff related to video i/o and showing gui windows) on Linux / macOS.

And thanks! 😃

@spencerahill

Great. It might be worth making this point more clearly in your documentation. I am new to opencv but I am otherwise not a novice, yet I still had this confusion. All the more so because the documentation of opencv itself (to me) is extremely haphazard.

Anyways, thanks again!

@skvark

I’ll update the readme file.

@shaikhrahil

@ skvark , I get the following error on giving pip install opencv-python on my pi zero. Any suggestions

import cv2
Traceback (most recent call last):
File «», line 1, in
File «/home/pi/.local/lib/python3.5/site-packages/cv2/init.py», line 4, in
from .cv2 import *
ImportError: libImath-2_2.so.12: cannot open shared object file: No such file or directory

@skvark

I’m sorry, this repository does not provide pre-built wheels for ARM-based platforms. You should contact the person who has created the wheels you are using.

@shaikhrahil

Alright , thanks for the quick reply @skvark !!

@abdur12345

i have error in my command prompt when i want to install opencv opencv-3.4.2-vc14_vc15.
when i type pip3 install opencv-python or
type pip install opencv-python and there is writing error
«Could not find a version that satisfies the requirement opencv-contrib-python (from versions: )
No matching distribution found for opencv-contrib-python»

@ZLCHEN007

@ skvark could you assist below:

>>> import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: /usr/local/lib/python3.6/site-packages/cv2.cpython-36m-aarch64-linux-gnu.so: undefined symbol: _Z11pyopencv_toIjEbP7_objectRT_PKc

@skvark

This is not a Q&A forum and the question you’re asking is not even related to this repository. Ask your question at Stack Overflow.

@Hooman08

@skvark Hi, obviously I’m new to these problems but I have a weird problem.
I’m using mac os and using mac terminal, I installed opencv and even I saw it’s version and I was able to import cv2 but I wonder why I’m not able to install cv2 in pycharm?
I tried but pycharm give me this error: ( Could not find a version that satisfies the requirement cv2 (from versions:
No matching distribution found for cv2)
and it also says «you are using pip version 10.0.1 however version 18.0 is available»
It’s really ridiculous because I updated pip to version 18 but apparently pycharm doesn’t understand …

@skvark

@opencv
opencv

locked as off-topic and limited conversation to collaborators

Sep 18, 2018

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

Читайте также:

  • Error no document variable supplied
  • Error no display environment variable specified linux
  • Error no display environment variable specified firefox
  • Error no devices emulators found перевод
  • Error no devices emulators found ubuntu

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

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