简体   繁体   English

无法在 PyCharm 上导入 cv2

[英]Cannot import cv2 on PyCharm

I am trying to import cv2 module in PyCharm, but it shows error.我正在尝试在 PyCharm 中导入cv2模块,但它显示错误。 I tried in terminal as well我也在终端中尝试过

pip install opencv-python
pip3 install cv2
pip install opencv-python
pip3 install cv2

and whatnot.什么的。

Trying to install opencv-python from terminal shows this尝试从终端安装opencv-python显示了这一点

Requirement already satisfied: opencv-python in ./anaconda3/lib/python3.6/site-packages (3.4.1.15)

and trying to install cv2 from terminal shows this并尝试从终端安装cv2显示了这一点

Could not find a version that satisfies the requirement cv2 (from versions: )
No matching distribution found for cv2

However, trying to import cv2 on Pycharm shows this :但是,尝试在cv2上导入 cv2 显示:

Pycharm Error Image Pycharm 错误图像

First, install the package named opencv-python via pip install opencv-python or use the GUI.首先,通过pip install opencv-python或使用 GUI pip install opencv-python名为opencv-python的包。

Second, just input import cv2 ;其次,只需输入import cv2 that is ok.那没问题。

Go to File->Settings->Project Interpreter and then add by '+' button 'opencv-python' module on this repository.转到 File->Settings->Project Interpreter,然后通过“+”按钮在此存储库上添加“opencv-python”模块。

It downloaded without an error for my PyCharm and also downloaded the dependencies as well.它为我的 PyCharm 下载没有错误,并且还下载了依赖项。

While creating a new project in PyCharm, please select 'Base Interpreter' option from drop-down similar to the one shown in this link: Creating new Project stage在 PyCharm 中创建新项目时,请从类似于此链接中显示的下拉列表中选择“Base Interpreter”选项: Creating new Project stage

Next, after successful creation of project and after downloading the opencv-python, it looks a shown in this link: Success message接下来,成功创建项目并下载opencv-python后,它看起来像这个链接中所示:成功消息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM