Python 如何在 Windows 上安装 OpenCV 并在不使用包管理器的情况下为 PyCharm 启用它

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32660114/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 11:59:59  来源:igfitidea点击:

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

pythonwindowsopencvinstallationpycharm

提问by webapp

I am trying to install and use OpenCV library for python development. I want to use it for PyCharm IDE. I am trying to do it without the package manager.

我正在尝试安装和使用 OpenCV 库进行 python 开发。我想将它用于 PyCharm IDE。我试图在没有包管理器的情况下做到这一点。

The environment is a windows 64 bit architecture. For Python I am using Python 2.7.10.

环境是windows 64位架构。对于 Python,我使用的是 Python 2.7.10。

I have already included the OpenCV directory in the system path.

我已经在系统路径中包含了 OpenCV 目录。

I am using python 2.7.10 interpreter for PyCharm and have installed the pip and numpy packages.

我正在为 PyCharm 使用 python 2.7.10 解释器并安装了 pip 和 numpy 包。

opencv version is 3.0.0

opencv 版本是 3.0.0

How do I enable OpenCV and make it working in PyCharm?

如何启用 OpenCV 并使其在 PyCharm 中工作?

采纳答案by webapp

I finally figured out on how to solve this issue:

我终于想出了如何解决这个问题:

Steps to follow:

要遵循的步骤:

  1. Install Python 2.7.10
  2. Install Pycharm(If you have not done it already)
  3. Download and install the OpenCV executable.
  4. Add OpenCV in the system path(%OPENCV_DIR% = /path/of/opencv/directory)
  5. Goto C:\opencv\build\python\2.7\x86 folder and copy cv2.pyd file.
  6. Goto C:\Python27\DLLs directory and paste the cv2.pyd file.
  7. Goto C:\Python27\Lib\site-packages directory and paste the cv2.pyd file.
  8. Goto PyCharm IDE and goto DefaultSettings>PythonInterpreter.
  9. Select the Python which you have installed on Step1.
  10. Install the packages numpy,matplotlib and pip in pycharm.
  11. Restart your PyCharm.
  12. PyCharm now has OpenCV library installed and working.
  1. 安装 Python 2.7.10
  2. 安装 Pycharm(如果你还没有安装过)
  3. 下载并安装 OpenCV 可执行文件。
  4. 在系统路径中添加OpenCV(%OPENCV_DIR% = /path/of/opencv/directory)
  5. 转到 C:\opencv\build\python\2.7\x86 文件夹并复制 cv2.pyd 文件。
  6. 转到 C:\Python27\DLLs 目录并粘贴 cv2.pyd 文件。
  7. 转到 C:\Python27\Lib\site-packages 目录并粘贴 cv2.pyd 文件。
  8. 转到 PyCharm IDE 并转到 DefaultSettings>PythonInterpreter。
  9. 选择您在 Step1 上安装的 Python。
  10. 在 pycharm 中安装包 numpy、matplotlib 和 pip。
  11. 重启你的 PyCharm。
  12. PyCharm 现在已安装并运行 OpenCV 库。

回答by Shojib Mahmud

nothing hard.

没什么难的。

?If you're using anaconda

?如果你使用蟒蛇

conda install opencv

?If you have python package manager pip

?如果你有 python 包管理器 pip

pip install opencv-python