skip to Main Content

I have a virtual environment with some installed packages and a notebook with some imports of packages that only exist in this environment.

I have done Ctrl + Shift + P > Python: Select Interpreter, and chosen my environment.

But, if I run the cell, it tells me ModuleNotFoundError, as it tries to use my global Python environment for the imports (if I install the packages globally the cell succeeds).

Therefore, the selected Interpreter is ignored, and the global environment is always used.

I also tried using my environment in: Jupyter: Select Interpreter to Start Jupyter Server, but the result did not change.

This problem does not exist in a python file, only in the jupyter notebooks.

How to fix it? Am I forced to install packages globally when using Jupyter Notebooks?

2

Answers


  1. try anaconda software, in this software contain jupiter notebook but its doesn’t contain any error to interpret python program and its interpreter is good working condition than VScode.

    Login or Signup to reply.
    • For .py scripts

      Ctrl+Shift+P –> Python: Select Interpreter

      enter image description here

    • For Jupyter Notebook

      Click Select Kernel in the upper right corner (Or the kernel version already shown) Select Python Environments....

      enter image description here

      enter image description here

    These are two different ways of choosing a python environment.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search