在Pycharm中导入OpenCV

时间:2015-02-13 10:20:21

标签: opencv pycharm

我想在pycharm中使用OpenCV(Python模块)。我在设置中设置了我的Python解释器,并将OpenCV路径(C:\opencv\build\python\2.7)添加到Python解释器路径中。不幸的是,pycharm无法导入OpenCV。值得注意的是,我在左侧面板(项目面板)中看到了cv2.pyd

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

请参阅How to install OpenCV on Windows and enable it for PyCharm without using the package manager

要遵循的步骤:

Install Python 2.7.10
Install Pycharm(If you have not done it already)
Download and install the OpenCV executable.
Add OpenCV in the system path(%OPENCV_DIR% = /path/of/opencv/directory)
Goto C:\opencv\build\python\2.7\x86 folder and copy cv2.pyd file.
Goto C:\Python27\DLLs directory and paste the cv2.pyd file.
Goto C:\Python27\Lib\site-packages directory and paste the cv2.pyd file.
Goto PyCharm IDE and goto DefaultSettings>PythonInterpreter.
Select the Python which you have installed on Step1.
Install the packages numpy,matplotlib and pip in pycharm.
Restart your PyCharm.
PyCharm now has OpenCV library installed and working.

如果您已经安装了pycharm,那么您可以输入:    pip install opencv-python    满意后,

然后转到文件,设置(在pycharm中)    项目,项目翻译,点击右上角的加号图标,

搜索opencv-python并安装包。