我希望通过Ubuntu 15.04机器中的命令安装opencv-python
pip3 install opencv-python
但是一旦我运行此命令,我就会收到以下错误:
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
非常感谢任何帮助。 谢谢!
答案 0 :(得分:4)
您可以从源安装opencv 请按照this链接进行操作 或者您可能需要使用以下命令升级您的pip3
pip3 install --upgrade pip
为了完整性(如果链接断开)我在这里列出了在Ubuntu上从源代码编译和安装OpenCV的步骤(使用python 3在Ubuntu 14.04 LTS上测试过)。
sudo apt-get update
sudo apt-get upgrade
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
conda create -n opencv-exmaple-env python=3.6
source activate opencv-exmaple-env # Activate the envirnoment
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
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
包含exptra功能,如标准关键点检测器和局部不变量描述符(如SIFT,SURF等)
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
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
ln -s /usr/local/lib/python3.6/site-packages/cv2.so /path-to-python-sitepackages-of-the-environment/cv2.so
import cv2
如果上面的代码运行没有错误,那么opencv已成功安装。
答案 1 :(得分:2)
首先使用sudo
升级点数。
arsho:~/workspace $ sudo pip3 install --upgrade pip
Successfully installed pip
现在使用opencv-python
命令再次安装sudo
。
arsho:~/workspace $ sudo pip3 install opencv-python
Successfully installed numpy-1.13.1 opencv-python-3.3.0.10
最后使用pip检查opencv-python
版本和位置信息。
arsho:~/workspace $ pip3 show opencv-python
---
Name: opencv-python
Version: 3.3.0.10
Location: /usr/local/lib/python3.4/dist-packages
Requires: numpy
我使用https://c9.io/中的Ubuntu 14.04.5 LTS
对此进行了测试。