问题描述
我正在尝试在 Jupyter notebook 上导入 cv2,但出现此错误:
I'm trying to import cv2 on Jupyter notebook but I get this error:
ImportError: No module named cv2
我很沮丧,因为我现在正在处理这个简单的问题几个小时.它适用于 Pycharm,但不适用于 Jupiter 笔记本.我已经将 cv2 安装到 Python2.7 的站点包中,将 Jupyter 的内核配置为 python2,浏览了文档,但我仍然不明白我缺少什么?
I am frustrated because I'm working on this simple issue for hours now. it works on Pycharm but not on Jupiter notebook. I've already installed cv2 into Python2.7's site packages, configured Jupyter's kernel to python2, browsed the documentation but I still don't get what I am missing ?
(我使用的是 Windows 10 并使用 microsoftcognitives api,这就是我需要导入这个包的原因.)
代码如下:
<ipython-input-1-9dee6ed62d2d> in <module>()
----> 1 import cv2
2 cv2.__version__
我应该怎么做才能完成这项工作?
What should I do in order to make this work ?
推荐答案
您的 Python 路径是否找对地方了?检查 python 在哪里寻找模块.在笔记本内试试:
Is your python path looking in the right place? Check where python is looking for the module. Within the notebook try:
import os
os.sys.path
cv2
模块是否位于任何这些目录中?如果不是,您的路径在错误的位置.如果它忽略了安装位置,请将其附加到您的 python 路径.您可以按照说明这里.
Is the cv2
module located in any of those directories? If not your path is looking in the wrong place. If it is overlooking the install location, append it to your python path. You can follow the instructions here.
这篇关于Jupyter 笔记本上的 cv2 导入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!