I'm trying to activate a conda environment in VSCode, but when importing modules inside my environment I get a ModuleNotFoundError.
First when I run conda list
in the terminal, the packages show up. To "activate" the environment, I selected it from Python: select interpreter in the command palette. When I use conda env list
, the correct environment is starred.
Sometimes, after activating a conda environment, I end up using the wrong Python version.
import sys
print(sys.executable)
The correct path should be <CondaPath>/envs/<Env>/bin/python
on Linux or <CondaPath>/envs/<Env>/python.exe
on Windows.
I'm not sure why, but reopening the terminal seemed to resolve the issue.