install pyopencv with pip on Mac OS X

2024/9/8 10:51:20

I am trying to install pyopencv with pip in OS X Mountain Lion and it fails by import setuptools. Following is my work. what is "Library" in setuptools? I have not seen that before. I already installed opencv via homebrew and other things. In doucmentation of pyopencv, it doesn't explain installation with pip only source install,

(img2)appleparan@LiamMac src $ brew install cmake
Warning: cmake-2.8.11.2 already installed
(img2)appleparan@LiamMac src $ brew install cmake --upgrade
Warning: cmake-2.8.11.2 already installed
(img2)appleparan@LiamMac src $ brew install opencv
Warning: opencv-2.4.6.1 already installed
(img2)appleparan@LiamMac src $ brew install boost
Warning: boost-1.54.0 already installed
(img2)appleparan@LiamMac src $ pip install pyopencv
Downloading/unpacking pyopencvCould not find a version that satisfies the requirement pyopencv (from versions: 2.0.wr1.0.1-demo, 2.0.wr1.0.1, 2.0.wr1.1.0, 2.1.0.wr1.0.0, 2.1.0.wr1.0.1, 2.1.0.wr1.0.2, 2.1.0.wr1.1.0, 2.1.0.wr1.2.0, 2.1.0.wr1.2.0-demo, 2.1.0.wr1.2.0)
Cleaning up...
No distributions matching the version for pyopencv
Storing complete log in /Users/appleparan/.pip/pip.log
(img2)appleparan@LiamMac src $ pip install pyopencv==2.1.0.wr1.2.0
Downloading/unpacking pyopencv==2.1.0.wr1.2.0Downloading pyopencv-2.1.0.wr1.2.0.tar.gz (363kB): 363kB downloadedRunning setup.py egg_info for package pyopencvTraceback (most recent call last):File "<string>", line 16, in <module>File "/Users/appleparan/.virtualenvs/img2/build/pyopencv/setup.py", line 92, in <module>from setuptools import setup, find_packages, Extension, LibraryImportError: cannot import name LibraryComplete output from command python setup.py egg_info:Traceback (most recent call last):File "<string>", line 16, in <module>File "/Users/appleparan/.virtualenvs/img2/build/pyopencv/setup.py", line 92, in <module>from setuptools import setup, find_packages, Extension, LibraryImportError: cannot import name Library----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /Users/appleparan/.virtualenvs/img2/build/pyopencv
Storing complete log in /Users/appleparan/.pip/pip.log
(img2)appleparan@LiamMac src $ python --version
Python 2.7.5
(img2)appleparan@LiamMac src $ pip freeze
Pillow==2.1.0
distribute==0.7.3
matplotlib==1.3.0
nose==1.3.0
numpy==1.7.1
pyparsing==2.0.1
python-dateutil==2.1
scipy==0.12.0
six==1.4.1
stevedore==0.12
tornado==3.1.1
virtualenv==1.10.1
virtualenv-clone==0.2.4
virtualenvwrapper==4.1.1
wsgiref==0.1.2
(img2)appleparan@LiamMac src $

EDIT: I found setuptools source has Library and Extension (https://bitbucket.org/pypa/setuptools/src/27df3c725f9696ba730456f3f444cc2fb5271d4b/setuptools/extension.py?at=default) But I don't know why it doesn't recognize.

My setuptools' verison is 1.1.6

(img2)appleparan@LiamMac src $ pip install setuptools --upgrade
Requirement already up-to-date: setuptools in /Users/appleparan/.virtualenvs/img2/lib/python2.7/site-packages/setuptools-1.1.6-py2.7.egg
Cleaning up...
(img2)appleparan@LiamMac src $
Answer

In recent version of setuptools, Library is inside of extension.py. pyopencv should import Library as setuptools.extension.Library not setuptools.Library.

https://en.xdnf.cn/q/72835.html

Related Q&A

OpenCV remap interpolation error?

Im using opencv remap function to map an image to another coordinate system. However, my initial tests indicate that there are some issues with the interpolation. Here, I give a simple example of a co…

Installing python with python win32 extensions on a network drive

I need to keep a large number of Windows XP machines running the same version of python, with an assortment of modules, one of which is python-win32. I thought about installing python on a network dri…

Python pytest hangs. For instance, pytest --version simply hangs

The following hangs:PS C:\Users\Fowler> pytest --version Notes:I am in Windows 10. By hang, I mean at least 5 minutes of waiting for the pytest --version to return... While waiting for pytest, pyth…

PyQt4 signals and slots

I am writing my first Python app with PyQt4. I have a MainWindow and a Dialog class, which is a part of MainWindow class:self.loginDialog = LoginDialog();I use slots and signals. Heres a connection mad…

Masking a pandas DataFrame with a numpy array vs DataFrame

I want to use a 2D boolean mask to selectively alter some cells in a pandas DataFrame. I noticed that I cannot use a numpy array (successfully) as the mask, but I can use a DataFrame. More frustratin…

How to explode multiple columns, different types and different lengths?

Ive got a DF with columns of different time cycles (1/6, 3/6, 6/6 etc.) and would like to "explode" all the columns to create a new DF in which each row is a 1/6 cycle.from pyspark import Row…

How to convert \xXY encoded characters to UTF-8 in Python?

I have a text which contains characters such as "\xaf", "\xbe", which, as I understand it from this question, are ASCII encoded characters. I want to convert them in Python to their…

Pandas One hot encoding: Bundling together less frequent categories

Im doing one hot encoding over a categorical column which has some 18 different kind of values. I want to create new columns for only those values, which appear more than some threshold (lets say 1%), …

How to pass classs self through a flask.Blueprint.route decorator?

I am writing my websites backend using Flask and Python 2.7, and have run into a bit of a problem. I like to use classes to enclose my functions, it makes things neat for me and helps me keep everythin…

why cannot I use sp.signal by import scipy as sp? [duplicate]

This question already has an answer here:scipy.special import issue(1 answer)Closed 8 years ago.I would like to use scipy.signal.lti and scipy.signal.impulse function to calculate the transfer function…