3

I wish to install opencv-python via the command in Ubuntu 15.04 machine

pip3 install opencv-python

But as soon as I run this command I get the following error :

Downloading/unpacking opencv-python
Could not find any downloads that satisfy the requirement opencv-python
Cleaning up...
No distributions at all found for opencv-python
Storing debug log for failure in /home/Nadeem/.pip/pip.log

Any help would be much appreciated. Thanks!!

2 Answers 2

4

You can install opencv from source.
Follow this link to do so.
Or you may need to upgrade your pip3 using the following command

pip3 install --upgrade pip

EDIT

For completeness(and in case the link is broken) I've listed here steps to compile and install OpenCV from source on Ubuntu(Tested on Ubuntu 14.04 LTS with python 3).

Step 1 Update the packages

sudo apt-get update
sudo apt-get upgrade

Step 2 Install dependencies

sudo apt-get install build-essential cmake git pkg-config # Developer tools required to compile opencv
sudo apt-get install libjpeg8-dev libtiff4-dev libjasper-dev libpng12-dev # Libraries required to read various image format from disk
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev # Libraries required to read various video formats
sudo apt-get install libgtk2.0-dev # Required by opencv for GUI features
sudo apt-get install libatlas-base-dev gfortran # Packages used by opencv to optimize various functions.

pip3 install --upgrade pip  

Step 3 setup virtual environment(using conda)

conda create -n opencv-exmaple-env python=3.6

source activate opencv-exmaple-env # Activate the envirnoment 

Step 4 Install packages required to compile opencv

sudo apt-get install python3.6-dev # If the python version is not 3.6 then make changes to this command accordingly. 
pip install numpy # This should be done after the environment in Step 3 is activated

Step 5: Build and install OpenCV 3.0 with Python 3.4+ bindings

5.1 Clone the opencv source

cd ~
mkdir opencv-source
cd opencv-source
git clone https://github.com/Itseez/opencv.git
cd opencv
git checkout 3.3.0 # Branch you want to compile from 

5.2 Clone Opencv Contrib rep

Contains exptra functionalities such as standard keypoint detectors and local invariant descriptors (such as SIFT, SURF, etc.)


cd ~
mkdir opencv-contrib
cd opencv-contrib
git clone https://github.com/Itseez/opencv_contrib.git
cd opencv_contrib
git checkout 3.3.0 # The version you want to compile

5.3 Compile,build and install

cd ~/opencv-source/opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_C_EXAMPLES=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv-contrib/opencv_contrib/modules \
    -D BUILD_EXAMPLES=ON ..
make -j4
sudo make install
sudo ldconfig

5.4 Link installed opencv object file to python site packages

ln -s /usr/local/lib/python3.6/site-packages/cv2.so /path-to-python-sitepackages-of-the-environment/cv2.so

6 Verify installation

import cv2

If the above code runs without error then opencv is installed successfully.

Sign up to request clarification or add additional context in comments.

Comments

3

At first upgrade pip using sudo.

arsho:~/workspace $ sudo pip3 install --upgrade pip                                                                                       
Successfully installed pip

Now install opencv-python again using sudo command.

arsho:~/workspace $ sudo pip3 install opencv-python
Successfully installed numpy-1.13.1 opencv-python-3.3.0.10

Finally check the opencv-python version and location information using pip.

arsho:~/workspace $ pip3 show opencv-python
---
Name: opencv-python
Version: 3.3.0.10
Location: /usr/local/lib/python3.4/dist-packages
Requires: numpy

I have tested this using Ubuntu 14.04.5 LTS in https://c9.io/.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.