我使用brew
来安装opencv 3.2.0,这对我来说似乎很成功。但是当我试图运行它时仍然找不到模块cv2
:
FF-MBP:read_video_frames ff$ python v2f.py
Traceback (most recent call last):
File "v2f.py", line 4, in <module>
import cv2
ImportError: No module named cv2
brew
安装如下所示:
FF-MBP:read_video_frames ff$ brew install opencv3
==> Installing opencv3 from homebrew/science
==> Installing dependencies for homebrew/science/opencv3: eigen, jpeg, libpng, libtiff, ilmbase, openexr
==> Installing homebrew/science/opencv3 dependency: eigen
==> Downloading https://homebrew.bintray.com/bottles/eigen-3.3.4.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring eigen-3.3.4.sierra.bottle.tar.gz
==> Using the sandbox
/usr/local/Cellar/eigen/3.3.4: 486 files, 6.5MB
==> Installing homebrew/science/opencv3 dependency: jpeg
==> Downloading https://homebrew.bintray.com/bottles/jpeg-8d.sierra.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring jpeg-8d.sierra.bottle.2.tar.gz
/usr/local/Cellar/jpeg/8d: 19 files, 708.3KB
==> Installing homebrew/science/opencv3 dependency: libpng
==> Downloading https://homebrew.bintray.com/bottles/libpng-1.6.29.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libpng-1.6.29.sierra.bottle.tar.gz
/usr/local/Cellar/libpng/1.6.29: 26 files, 1.2MB
==> Installing homebrew/science/opencv3 dependency: libtiff
==> Downloading https://homebrew.bintray.com/bottles/libtiff-4.0.8.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libtiff-4.0.8.sierra.bottle.tar.gz
/usr/local/Cellar/libtiff/4.0.8: 245 files, 3.4MB
==> Installing homebrew/science/opencv3 dependency: ilmbase
==> Downloading https://homebrew.bintray.com/bottles/ilmbase-2.2.0.sierra.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring ilmbase-2.2.0.sierra.bottle.2.tar.gz
/usr/local/Cellar/ilmbase/2.2.0: 362 files, 5.6MB
==> Installing homebrew/science/opencv3 dependency: openexr
==> Downloading https://homebrew.bintray.com/bottles/openexr-2.2.0.sierra.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring openexr-2.2.0.sierra.bottle.1.tar.gz
/usr/local/Cellar/openexr/2.2.0: 131 files, 11.2MB
==> Installing homebrew/science/opencv3
==> Downloading https://homebrew.bintray.com/bottles-science/opencv3-3.2.0.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring opencv3-3.2.0.sierra.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because opencv3 and opencv install many of the same files.
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/opencv3/bin:$PATH"' >> ~/.bash_profile
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/opencv3/lib
CPPFLAGS: -I/usr/local/opt/opencv3/include
If you need Python to find bindings for this keg-only formula, run:
echo /usr/local/opt/opencv3/lib/python2.7/site-packages >> /usr/local/lib/python2.7/site-packages/opencv3.pth
==> Summary
/usr/local/Cellar/opencv3/3.2.0: 286 files, 47.4MB
是因为opencv 3.0+
仅与Python3.x
合并吗?我试过import cv3
- 没有用。
感谢任何输入。谢谢!
Mac OS X:Sierra 10.12.5
Python:2.7
OpenCV:3.2.0
答案 0 :(得分:0)
使用pip install
在Windows中安装opencv。要先安装,请转到cmd。浏览到cmd中的opencv。 pip install opencv
安装它。
答案 1 :(得分:0)
实际上这已经解决了!我设法在PyCharm上正确安装它。教程:https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html#d64763e97