I am using VS-Code and anaconda environment for python interpreter. I select the exact anaconda base environment by ctrl + shift + ` and it also reflects in the downside panel of vscode. But, when I checked the python version it shows my system's default python environment 3.7.9. If you see the below screenshot than, the anaconda environment is with 3.8.3.
To check & change vs code interpreter:
- In top left menu bar Click view
- In the dropdown menu, Click Command Palette
- Click Python: Select Interpreter
- Choose & Click on your desired Interpreter
Another way to be sure to use anconda interpreter, open anaconda navigator and launch vs code from there.
For those who have tried these steps:
- select different interpreter
- reboot VScode
- reinstall VScode Python extension and delete its folders
and have achieved nothing.
Probably you are working in the workspace and not in folder. You may have set interpreter at workspace level, which can't be used in one of the folders of the workspace. Try opening your folder separately from the workspace and select interpreter you want. This worked for me.
For me it worked by changing the final step in the selection process:
The start is as usual:
Command Palette
> Python: Select Interpreter
+ Enter interpreter path
but then, not picking the option
Find... Browse your file system to find a Python interpreter
(which opens a file explorer to select the interpreter)
but instead
- directly enter the full path in the text field and press Enter.
In theory, both should have the same effect, but for my case they did not. (I had tried reloading the window, restarting vscode, adding the venv to the known venv folders in the workspace settings, even recreating the venv in case something went wrong there, but none of these options worked.)
Changing the version in VSCode does not change the the instance that your PS instance will use. Try doing where python to see where the V3.7.9 that your PS instance is picking up is. Then remove that version from the environment variables and add the path to the V3.8.3 instead.
Additionally you can do: To forcefully use v3.8.3
- Specify python version in command
py -3.8 <command>
- OR set PY_PYTHON environment variable to set which version to use. Take a look at this for further help Python docs
after changing the environment, you can restart the vs code again. it might be changed now. if not, then try changing now againg by clicking the interpreter name which is displayed on left bottom of the vscode window
If nothing worked from the above-suggested solution, you could try this.
Create a virtual environment in anaconda and activate it
conda create -n <environment_name> python=3.8.3
conda activate <environment_name>
Then you can directly open VS Code from same Anaconda terminal by typing
code
In the opened VS Code, you will see python 3.8.3 will be activated. Instead of the default system python 3.7.9
In my case helped to uncheck at User settings -> Extensions -> Python:
- Terminal: Activate Env In Current Terminal
- Terminal: Activate Environment
but I don`t know why.
I was able to fix this issue by removing the python.defaultInterpreterPath setting from my settings.json. May be worth checking your user settings if this problem persists.
Another thing I realized is that I have to right-click on the python file and click Run Python file in Terminal, if I just run it with a python command in the powershell window, it's not using the right python executable.
I don't have the conventional way of doing that but when I faced this issue I simply noted the python version that it was showing and then I deleted it as soon as I deleted it the system made another python version as the default python version and then I reinstalled the python version that I deleted and it worked. like I was able to change the python version in VS code.
here is how I resolved it with step by step investigation:
first, check all the versions you have installed for example open uninstall program to check all the versions available, uninstall those you don't need
second, find the path to all your existing python versions, default should be "%AppData%\Local\Programs\Python\PythonXXX" for windows users
open "edit system environment", make sure you have the correct python path configured, for example in PATH you have path to python and pip:
"%AppData%\Local\Programs\Python\Python312"
"%AppData%\Local\Programs\Python\Python312\Scripts"
open powershell or cmd, execute:
python -V
pip list -v
make sure both are consistent with what you configured in step 3
close all the vscode instances if reload window not work, close all and open up again, then the interpreter selection should work
for best practice, try the virtual env introduced in the link below
refer to:
To check & change vs code interpreter:
- In top left menu bar Click view
- In the dropdown menu, Click Command Palette
- Click Python: Select Interpreter
- Choose & Click on your desired Interpreter
Another way to be sure to use anconda interpreter, open anaconda navigator and launch vs code from there.
© 2022 - 2025 — McMap. All rights reserved.