1

I am trying to work with cvzone library in Python using VSCode. I have installed the library using pip install cvzone. But when trying to import the library, ModuleNotFoundError is being raised.

import cvzone

Output

ModuleNotFoundError: No module named 'cvzone'
  • I have checked that the correct environment is activated in terminal
  • Have checked that the interpreter is correctly selected
  • Ran pip list and ensured that the library is installed
  • Tried to import using python in terminal, and worked correctly

I tried to run the same in Colab and it was successfully imported. But when trying to run in Jupyter Notebook in VSCode, it is not working.

  • Using cvzone 1.5.6
soucs
  • 35
  • 5
  • 1
    In the notebook where you want to run the import, make a cell above that and run `%pip install cvzone`. Run that and then restart the kernel. Now try your import. The magic install command insures the installation occurs in the environment that is backing the kernel underlying the notebook. See more about the modern `%pip install` command [here](https://discourse.jupyter.org/t/why-users-can-install-modules-from-pip-but-not-from-conda/10722/4?u=fomightez). – Wayne Mar 15 '23 at 20:34

2 Answers2

1

But when trying to run in Jupyter Notebook in VSCode, it is not working.

Please check whether you have chosen the correct Python kernel in Jupyter-Notebook.

enter image description here

The problem you meet may be caused by the python interpreter you selected in vscode was different from the kernel in jupyter.

Read document for more details.

MingJie-MSFT
  • 5,569
  • 1
  • 2
  • 13
0

I deleted the virtualenv, created a new one (with another name. First, I created one with the same name, but it showed the same issue), and reinstalled all the packages. Then it worked! I don't know what was wrong, but anyway... Thank you all for answering.

soucs
  • 35
  • 5