ModuleNotFoundError:没有名为"cv2"的模块 [英] ModuleNotFoundError: No module named 'cv2'

查看:286
本文介绍了ModuleNotFoundError:没有名为"cv2"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很长时间以来一直在处理此错误.我有Python 3.6和Python 2.7.我尝试分别在Python 2.7和Python 3.6中安装opencv 2和3.我知道我正在使用的python解释器,可以在需要时在它们之间互换.

当我运行Python解释器并编写import cv2时,它确实将其导入.当我从命令提示符运行代码时,它说 ModuleNotFoundError:没有名为"cv2"的模块. 模块已安装. cv2.pyd文件位于C:\Python27\Lib\site-packages中,我附上了显示Python27中模块的屏幕截图

我用过pip install opencv-python.我已经从其他站点下载了该模块,并手动将其复制粘贴到正确的文件夹中.什么都没用,我现在严重缺乏想法.

我在Windows 10上通过anaconda安装了python 3.6,并且直接安装了python 2.7.两者都在路径中设置了变量

解决方案

面对Windows 10上的相同问题,我从 Mark Jay视频中提供了更多信息. /p>

:D

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.

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

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.

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

解决方案

Faced with the same issue on Windows 10 I downloaded the open cv binary from the Unofficial Windows Binaries for Python Extension Packages.

Search the page for opencv and for and download the correct .whl for your system. Then pip install it. By example, on my system, after opening a cmd window I typed the following.

pip install opencv_python-3.4.1-cp36-cp36m-win_amd64.whl

I then opened python and the following worked

import cv2
print(cv2.__version__)

More info is available in this Mark Jay video.

:D

这篇关于ModuleNotFoundError:没有名为"cv2"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆