2

As the title suggest, VSCode is using the wrong interpreter, even though the correct one is listed. As can be seen in the picture, my python script errors out as it cannot find some packages within the environment. After checking which interpreter it is using, it says python 3.8.12 (my base environment). The environment that I am running my code in should be python 3.9.7 (see bottom right of picture).

Now how do I ensure the code runs in the right environment?

error when running code

2 Answers 2

3

I had the same problem for a multi-project workspace. I had to select the interpreter for the whole workspace (the last item "Select at workspace level" in the ctrl-shift-p dialog), then it worked flawlessly.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use shortcut keys Ctrl+shift+P to manually adjust the interpreter.

4 Comments

as you can see in the bottom right, the selected interpreter already is the one I want to have. But any code will be ran on a different interpreter.
Then I think this should be related to your CONDA environment settings. The actual reading is the Python interpreter configured by your system. You can read this article to reset the CONDA environment.conda.io/projects/conda/en/latest/user-guide/tasks/…
Running code with "python script.py" seemed to select the right interpreter.
and then what??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.