Python ModuleNotFoundError: 没有名为“cv2”的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46854330/
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
ModuleNotFoundError: No module named 'cv2'
提问by hkhan
I have been working on this error for a long time now. I have Python 3.6 and Python 2.7. I have tried to install opencv 2 and 3 in Python 2.7 and Python 3.6 respectively. I know the python interpreter I am using and I can interchange between them when I want.
我已经研究这个错误很长时间了。我有 Python 3.6 和 Python 2.7。我曾尝试分别在 Python 2.7 和 Python 3.6 中安装 opencv 2 和 3。我知道我正在使用的 python 解释器,我可以在需要时在它们之间进行交换。
When I run Python interpreter and write import cv2
it does import it. When I run the code from command prompt it says ModuleNotFoundError: No module named 'cv2'.
The module is installed. The cv2.pyd file is in C:\Python27\Lib\site-packages
I have attached a screen shot which shows the modules in Python27
当我运行 Python 解释器并编写import cv2
它时,它会导入它。当我从命令提示符运行代码时,它说ModuleNotFoundError: No module named 'cv2'。模块已安装。cv2.pyd 文件在C:\Python27\Lib\site-packages
我附上了一个屏幕截图,其中显示了 Python27 中的模块
I have used pip install opencv-python
. I have downloaded the module from different sites and manually copy pasted it in the correct folder. Nothing works and I am seriously short of ideas now.
我用过pip install opencv-python
。我已经从不同的站点下载了该模块并手动将其复制粘贴到正确的文件夹中。没有任何效果,我现在严重缺乏想法。
EDIT:I am on windows 10 with python 3.6 installed through anaconda and python 2.7 installed directly. Both have their variables set in the path
编辑:我在 Windows 10 上,通过 anaconda 安装了 python 3.6,直接安装了 python 2.7。两者都在路径中设置了变量
采纳答案by SpeedCoder5
Faced with the same issue on Windows 10 I downloaded the open cv binary from the Unofficial Windows Binaries for Python Extension Packages.
面对 Windows 10 上的相同问题,我从Unofficial Windows Binaries for Python Extension Packages下载了 open cv 二进制文件。
Search the page for opencvand for and download the correct .whl for your system. Then pip install it. By example, on my system, after opening a cmdwindow I typed the following.
在页面上搜索opencv并为您的系统下载正确的 .whl。然后pip安装它。例如,在我的系统上,打开cmd窗口后,我输入了以下内容。
pip install opencv_python-3.4.1-cp36-cp36m-win_amd64.whl
I then opened python and the following worked
然后我打开了python,以下工作
import cv2
print(cv2.__version__)
More info is available in this Mark Jay video.
此Mark Jay 视频中提供了更多信息。
:D
:D
回答by Mikeologist
In Windows 10 you can install it as
在 Windows 10 中,您可以将其安装为
pip install opencv-python
this will allow you to import cv2 module
这将允许您导入 cv2 模块