问题描述
我无法运行示例Python程序.当执行Python命令来自opencv import cv"时,我收到消息"ImportError:没有名为_cv的模块". site-packages目录中有一个过时的_cv.pyd,但任何地方都没有_cv.py.请参阅下面的步骤5.
I cannot get the example Python programs to run. When executing the Python command "from opencv import cv" I get the message "ImportError: No module named _cv". There is a stale _cv.pyd in the site-packages directory, but no _cv.py anywhere. See step 5 below.
MS Windows XP,VC ++ 2008,Python 2.6,OpenCV 2.0
MS Windows XP, VC++ 2008, Python 2.6, OpenCV 2.0
这就是我所做的.
- 下载并运行了OpenCV2.0的MS Windows安装程序.
- 下载并安装了CMake
- 下载并安装了SWIG
- Ran CMake.在CMake GUI中取消选中"ENABLE_OPENMP"后,我能够使用INSTALL.vcproj和BUILD_ALL.vcproj构建OpenCV.我不知道有什么区别,所以我在这两个项目文件下构建了所有内容. C示例程序运行良好.
- 将OpenCV2.0/Python2.6/lib/site-packages的内容复制到我安装的Python2.6/lib/site-packages目录中.我注意到它包含一个旧的_cv.pyd和一个旧的libcv.dll.a.
推荐答案
在步骤1(安装程序)之后,只需将C:\OpenCV2.0\Python2.6\Lib\site-packages
的内容复制到C:\Python26\Lib\site-packages
(假定为标准安装路径)即可.就是这样.
After Step 1 (Installer) just copy the content of C:\OpenCV2.0\Python2.6\Lib\site-packages
to C:\Python26\Lib\site-packages
(standard installation path assumed).That's all.
如果您安装了网络摄像头,则可以尝试在C:\OpenCV2.0\samples\python
If you have a webcam installed you can try the camshift.demo in C:\OpenCV2.0\samples\python
不赞成使用的东西(C:\OpenCV2.0\samples\swig_python
)目前无法正常工作,如上面的人所写. OpenCV人员正在为此工作.这是全图:
The deprecated stuff (C:\OpenCV2.0\samples\swig_python
) does not work at the moment as somebody wrote above. The OpenCV People are working on it. Here is the full picture:
04/03/10 [james]为新的Python重写示例3月4日下午5:36
通过API link://twitter.com/opencvlibrary
04/03/10 [james]rewriting samples for new Python 5:36 PM Mar 4th
via API link://twitter.com/opencvlibrary
09/12/31我们对OpenCV的软件越来越认真 工程.现在,我们有了完整的C ++和Python接口. 链接://opencv.willowgarage.com/wiki/OpenCV%20Monthly
12/31/09 We've gotten more serious about OpenCV's software engineering. We now have a full C++ and Python interface. link://opencv.willowgarage.com/wiki/OpenCV%20Monthly
9/30/09几个(实际上,大多数)基于SWIG的Python示例不起作用 现在正确.原因是此问题正在调查中, OpenCV Python软件包的中间更新将发布 问题一解决就解决. 链接://opencv.willowgarage.com/wiki/OpenCV%20Monthly
9/30/09 Several (actually, most) SWIG-based Python samples do not work correctly now. The reason is this problem is being investigated and the intermediate update of the OpenCV Python package will be released as soon as the problem is sorted out. link://opencv.willowgarage.com/wiki/OpenCV%20Monthly
这篇关于OpenCV 2.0和Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!