ImportError: No module named 'cv2' using jupyter

戏子无情 提交于 2019-12-07 01:58:19

问题


I am trying to import OpenCV into my ipynb using Jupyter. I kept getting :

ImportError: No module named 'cv2'

import cv2
import pandas as pd
import numpy as np
import matplotlib

from matplotlib import pyplot as plt
import seaborn as sns

Any idea how to import cv2 in jupyter?


回答1:


If you have already installed opencv, then its possible that your notebook and your opencv library are in 2 different python environments. The following has helped me in the past:

  1. Open your notebook
  2. In an new cell type:

!pip install opencv-python

Note, that the ! is deliberate. This will install open-cv in your current notebook environment.




回答2:


You can type

which jupyter-notebook

if it's not in the envs of opencv-python installed, you should install jupyter in the envs:

condda install jupyter-notebook


来源:https://stackoverflow.com/questions/32777807/importerror-no-module-named-cv2-using-jupyter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!