0

I am currently studying Pytorch and trying to use the cv2 module. I am using Jupyter notebook and Windows.

I have installed opencv like this:

!pip install opencv-python

When I choose the kernel (by change kernel option) Python3 and import cv2 then there is no problem.

But when I choose the kernel Pytorch and import cv2, then there is an error:

ModuleNotFoundError: No module named 'cv2'

This must be a basic question but I can't find out what the problem is.

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
456 123
  • 111
  • 1
  • 4

2 Answers2

4

I found the answer to this problem here:

First do run these commands

$ conda update anaconda-navigator

$ conda update navigator-updater

then the issue for the instruction below will be resolved

For windows if you have anaconda installed, you can simply do:

pip install opencv-python

or

conda install -c https://conda.binstar.org/menpo opencv

If you're on linux you can do :

pip install opencv-python

or

conda install opencv 
Jab
  • 26,853
  • 21
  • 75
  • 114
mauza
  • 63
  • 1
  • 6
-1

If you run pip install opencv failed. You can download the whl file in here and then install it locally:

pip install opencv_python-4.5.5.64-cp36-abi3-win_amd64.whl