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
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.
For
.py
scriptsCtrl+Shift+P –> Python: Select Interpreter
For Jupyter Notebook
Click
Select Kernel
in the upper right corner (Or the kernel version already shown) SelectPython Environments...
.These are two different ways of choosing a python environment.