2015-12-18 72 views
3

我使用OpenCV 3和Python 2.7并使用PyCharm进行编码。代码工作正常,但PyCharm不会将cv2识别为模块。它用红线强调它,所以它不会在智能菜单中显示它的功能。PyCharm不会将cv2识别为模块

我试图设置环境变量OPENCV_DIR但它没有工作

OpenCV的提取在 F:\ OpenCV的和 Python是安装在 C:\ Python27

有什么不对?

+0

已复制cv2.pyd纠正蟒蛇lib文件夹? –

+0

我将它复制到C:\ Python27 \ Lib \ site-packages作为opencv教程说 –

+0

试试这个解决方案http://stackoverflow.com/a/19885882/2341815 –

回答

3

我有同样的问题,恐怕目前还没有解决方案。你可以阅读更多有关该问题的here

的问题是,OpenCV的不包括需要.py文件有可能是为什么PyCharm不拿起包以及自动完成。

要确定我们在同一页面上,当您进入文件>默认设置>默认项目>项目解释器并选择python 2.7解释器时,它是否在软件包中列出了cv2opencv

编辑:我能够得到它与anaconda而不是Python的工作。刚刚安装了anaconda,并做了一切,就像我会用python(复制cv2它将在python中)。希望它可以帮助你!

+0

建议您问自己的问题,作为评论原帖子(问题)。 – gnerkus

+0

我安装了OpenCV 2.4.9,它工作正常。 –

3

按照链接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. 
+0

我安装了OpenCV 2.4.9,它工作正常。 –

0

我跟随在webapp响应的步骤之后,它不工作,我决定重新安装pycharm IDE,这个工程我。 希望它有帮助。

0

从事过Pycharm 4.0版本

遵循以下步骤:

  1. 围棋在搜索栏中Pycharm IDE Window

  2. 搜索项目解释文件>设置。

  3. 从可用选项中单击任意程序包
  4. 从可以安装任何程序包的位置打开程序包窗口。

我已经安装了OpenCV的-Python包运行OpenCV的命令