如何在Ubuntu上安装PyOpenCV

时间:2014-10-23 20:48:11

标签: python

我正在尝试使用setuptools在Ubuntu 14.04上安装PyOpenCV。我试过的时候

python setup.py config 

我收到了错误

ImportError: cannot import name Library

我在上一个问题的答案中发现修复是要改变

from setuptools import Library  

from setuptools.extension import Library
在setup.py中

。现在,当我运行setup.py时,错误发生在它生成的config.py脚本中:

$ python setup.py config
Configuring PyOpenCV via CMake...
<snip>
-- Configuring done
-- Generating done
-- Build files have been written to:  /home/saul/Downloads/pyopencv/build
Traceback (most recent call last):
File "setup.py", line 137, in <module>
import config as C
File "/home/saul/Downloads/pyopencv/config.py", line 1, in <module>
from setuptools import Extension, Library
ImportError: cannot import name Library

config.py的第一行包含相同的导入错误。我当然可以更正config.py,但我不知道如何恢复构建过程。

失败点的setup.py文本是:

    import config as C

setup(
name = "pyopencv",
version = C.PYOPENCV_VERSION,
description = DOCLINES[0],
author = 'Minh-Tri Pham',
author_email = 'pmtri80@gmail.com',
url = 'http://code.google.com/p/pyopencv/',
license = 'New BSD License',
platforms = 'OS Independent, Windows, Linux, MacOS',
classifiers = filter(None, CLASSIFIERS.split('\n')),
long_description = "\n".join(DOCLINES[2:]),
ext_modules=C.extension_list,
install_requires = ['numpy>=1.2.0'],
package_data = {'pyopencv': ['*.dll']},
include_package_data = True,
# zip_safe = (os.name!='nt'), # thanks to ffmpeg dependency
package_dir={'':'package'},
packages = find_packages('package'),
)

您能告诉我如何解决这个问题,或者建议另一种安装pyOpenCV的方法吗?

1 个答案:

答案 0 :(得分:6)

有很多简单的方法,打开终端并输入:

sudo apt-get install python-opencv