解决方案 https://stackoverflow.com/questions/32777807/importerror-no-module-named-cv2-using-jupyter
原文:
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.
总之就是
然后莫名其妙地好了
出错原因应该就是jupyter notebook的python环境和你已经装过的opencv的环境不一样。
出现这种情况的原因是juypter notebook和spyder等都是安装Anaconda时安装的,它们依赖的是Anaconda所配置的库路径,而Anaconda所配置的库路径没有包含当前的python的库路径。
jupyter的库路径是这样的
pip安装的地方是这样的