1. Under the View menu select Command Palette... F1 (or press F1 key).

  2. Type Python: Select Interpreter.

  3. Choose which Python version to use by default [1].


[1] You can safely disregard the "Recommended" hint, which is usually the bare bones system one, without access to your custom packages.

Answer from Natsfan on Stack Overflow
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ python โ€บ environments
Python environments in VS Code
November 3, 2021 - Select the Python version in the Status Bar to switch environments. How the extension auto-selects: When you open a workspace without explicitly selecting an environment, the extension chooses one automatically in the following order: ...
Discussions

VScode using the wrong version of python for virtual environments
Your submission in r/learnpython may be automatically removed because you used imgbb.com. The reddit spam filter is very aggressive to this site. Please use a different image host. Please remember to post code as text, not as an image. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
๐ŸŒ r/learnpython
3
1
January 13, 2023
windows - How to specify the python version for VSCode virtual environment, when I have multiple python versions intalled? - Stack Overflow
I have both 64-bit and 32-bit Python installed. I was trying to create a virtual environment using the 32-bit Python.exe file in VSCode. I selected that version in the Python: Select Interpreter fo... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How can I set up a virtual environment for Python in Visual Studio Code? - Stack Overflow
Your Python virtual environment will now be created, and it will be located in a directory named .venv within your project folder. This method allows you to easily manage your Python environments within VSCode and select the Python version and package dependencies that suit your project's requirements. ... Activate your environment. ... When I run activate in cmd terminal in VS Code it is activated. However I need to change ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How do you get Visual Studio Code to use different Python interpreter? - Stack Overflow
I'm new to VS Code/Python, and I'm trying to get VSCode to run a specific version of Python (seems I have multiple versions installed). I tried the following code: import sys print(sys.version) W... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Posit
docs.posit.co โ€บ ide โ€บ server-pro โ€บ user โ€บ vs-code โ€บ guide โ€บ python-environments.html
Python Environments in VS Code โ€“ Posit Workbench Documentation Release 2026.01.2
We recommend that admins install all versions of Python in /opt/python. If you are unsure where Python has been installed on your server please reach out to your server administrator. Now you can configure VS Code always to use this virtual environment when working on this project.
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ visualstudio โ€บ python โ€บ selecting-a-python-environment-for-a-project
Switch between Python environments - Visual Studio (Windows) | Microsoft Learn
April 18, 2024 - Or, on the Python toolbar, select Add Environment from the Environment dropdown menu. In the Add Environment dialog, select the Existing environment tab. Expand the Environment dropdown list and choose your desired environment, then select Add.
๐ŸŒ
CodeGenes
codegenes.net โ€บ blog โ€บ how-to-change-python-version-in-vscode
Mastering Python Version Switching in Visual Studio Code โ€” codegenes.net
After changing the Python interpreter in VSCode, run this script to verify that the correct Python version is being used. Open the VSCode settings by pressing Ctrl+, (Windows/Linux) or Cmd+, (Mac). Search for python.pythonPath.
๐ŸŒ
Medium
medium.com โ€บ ai-innovations-digest โ€บ how-to-set-a-virtual-environmet-in-vs-code-634c296d19de
How to set a virtual environment in VS code | by Ganesh Prasad Bhandari | AI Innovations Digest | Medium
September 28, 2024 - Select Kernel: Click on the kernel name (top-right in the notebook interface) and choose the desired Python interpreter or environment. Updating Python: To update Python, download the newer version and adjust the PATH as necessary.
Find elsewhere
๐ŸŒ
Fmyly
en.fmyly.com โ€บ article โ€บ how-to-change-the-python-version-in-visual-code
How to Change the Python Version in Visual Studio Code: A Comprehensive Guide - Fmyly
January 16, 2026 - Standard Naming and Location: Name your virtual environment something standard like `.venv` or `venv` and place it directly within your projectโ€™s root directory. VS Codeโ€™s Python extension has built-in heuristics to detect these. Workspace Settings (`.vscode/settings.json`): The most reliable way is for VS Code to save your selection.
Top answer
1 of 1
8

There are two concepts you are mixing: The Python Interpreter used by VS Code and the py launcher. In addition to that, there is python command. I will try to explain how they are configured and how they affect and what.

1. python command

1.1. Used version specified by

PATH environment variable only. The first folder in the Process PATH environment variable with python.exe is used. Process PATH is formed by combining User and System PATH variables when starting the process. Subprocesses, such as the integrated terminal of VS Code inherit the PATH of the parent process during initialization.

  • If virtual environment is active, the used version is the one pointed by the home key of the pyvenv.cfg. Activating virtual environment modifies the PATH of the shell.

1.2. Used in

When you run python command in a terminal.

2. py command

The py command is the Python Launcher for Windows, added in Python 3.3.

2.2 Used version Specified by

First, these are checked in this order

  • An active virtual environment
  • A shebang line in the script (if present)
  • With -2 or -3 flag a matching PY_PYTHON2 or PY_PYTHON3 Enviroment variable
  • A PY_PYTHON Enviroment variable
  • From [defaults] in py.ini in your %LOCALAPPDATA%\py.ini
  • From [defaults] in py.ini beside py.exe (use where py to locate)

It will always use the latest installed version, if not specified otherwise.

3. VS Code python.pythonPath

3.1. Used version specified by

In the .vscode\settings.json, the python.pythonPath key.

3.2. Used in

  • When you use Python: Run Python File in Terminal in VS Code
  • When you use Run: Run Without Debugging for .py file in VS Code
  • When you use Run: Start Debugging for .py file in VS Code
  • When you launch a new integrated terminal in VS Code, if the python.exe is inside a virtual environment, it will be activated.
  • Language services, like auto-complete, linting, syntax-checking, formatting. Only those that are not ran using the integrated terminal.

Specifically, the python.pythonPath setting does not affect to what happens, if you run py or python in the integrated terminal. It can only affect it if you have specified a virtual environment for python.pythonPath, and launched new integrated terminal, and the virtual environment is activated. That is, there is no extra "magic" added VS Code or the VS Code integrated terminal.

The integrated terminal is (by default) just a regular Powershell. It has no clue about your python.pythonPath settings in your VS Code.

How to force using the 32-bit Python 3.7?

You can create a virtual environent with python 3.7-32bit using

py -3.7-32 -m venv 32_bit_env

Or, the full filepath to the 32-bit v.3.7. python.exe, assuming Powershell (hence &):

& "C:\some\path\Python 3.7 32-bit\python.exe" -m venv 32_bit_env

You can check the full filepath with py -0p, if you need to. Then, you can then make this virtual environment to be automatically activated in new VS Code integrated terminals, by editing the settings.json:

{
    "python.pythonPath": "C:/tmp/someproj/my_venv/Scripts/python.exe"
}

Note that every \ in the entry has to be replaced with either \\ or /. The python.pythonPath has to be absolute.

๐ŸŒ
Visual Studio Marketplace
marketplace.visualstudio.com โ€บ items
Python Environments - Visual Studio Marketplace
Extension for Visual Studio Code - Provides a unified python environment experience
Top answer
1 of 16
258
  • I have been using Visual Studio Code for a while now and found an another way to show virtual environments in Visual Studio Code.

  • Go to the parent folder in which venv is there through a command prompt.

  • Type code . and Enter. [It is working on both Windows and Linux for me.]

  • That should also show the virtual environments present in that folder.

Original Answer

I almost run into same problem every time I am working on Visual Studio Code using venv. I follow the below steps:

  1. Go to menu File โ†’ Preferences โ†’ Settings.

  2. Click on Workspace settings.

  3. Under Files:Association, in the JSON: Schemas section, you will find Edit in settings.json. Click on that.

  4. Update "python.defaultInterpreterPath": "Your_venv_path/bin/python" under workspace settings. (For Windows): Update "python.defaultInterpreterPath": "Your_venv_path\Scripts\python.exe" under workspace settings.

  5. Restart Visual Studio Code in case if it still doesn't show your venv.

Note: Use python.pythonPath instead of python.defaultInterpreterPath for older versions.

2 of 16
209

With a newer Visual Studio Code version it's quite simple.

Open Visual Studio Code in your project's folder.

Then open Python Terminal (Ctrl + Shift + P: Python: Create Terminal)

In the terminal:

python -m venv venv

You'll then see the following dialog:

Click Yes; and your venv is ready to go.

Open a new terminal within VSCode Ctrl + Shift + P and you'll see that venv is getting picked up; e.g.: (venv) ...

You can now instal packages as usual, e.g., pip install sklearn

To keep track of what is installed: pip freeze > requirements.txt


For the older versions of VSCode you may also need to do the following:

Then Python: Select Interpreter (via Ctrl + Shift + P)

And select the option (in my case towards the bottom)

Python 3.7 (venv) ./venv/Scripts/python.exe

If you see

Activate.ps1 is not digitally signed. You cannot run this script on the current system.

you'll need to do the following: https://stackoverflow.com/a/18713789/2705777

For more information see: Global, virtual, and conda environments

Installing Modules

Ctrl + Shift + P and Terminal: Create New Integrated Terminal

from the terminal

Windows: .\.venv\Scripts\activate

Linux: ./.venv/bin/activate

You can now instal packages as usual, e.g., pip install sklearn.

For Jupyter, you need to do more - Jupyter notebooks in Visual Studio Code does not use the active virtual environment

๐ŸŒ
TMS Outsource
tms-outsource.com โ€บ home โ€บ how to change python interpreter in vscode
How to Change Python Interpreter in VSCode - TMS Outsource
November 12, 2025 - Clicking it provides a two-click solution for switching Python versions during active development. No keyboard shortcuts to remember. Just click and pick. Virtual environment interpreters appear in the selection list with their folder path displayed, typically showing โ€œ.venvโ€ or โ€œenvโ€ followed by the workspace location where VSCode detected them.
๐ŸŒ
Quora
quora.com โ€บ How-can-I-change-the-python-version-in-my-visual-studio-code-terminal
How to change the python version in my visual studio code terminal - Quora
Answer (1 of 3): This is how I solved the issue of using different versions of Python on Windows. 1. Download Python 2.x and Python 3.x , install them. 2. Add [code ]C:\Python35;C:\Python35\Scripts;C:\Python27;C:\Python27\Scripts[/code] to environment variable [code ]PATH[/code]. 3. Go to [code ...
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how to install a different python version inside a virtual environment
r/learnpython on Reddit: How to install a different Python version inside a virtual environment
December 11, 2023 -

Hi Guys, I'm a total newbie to Python. But I have to work with two different Python versions as one of my new projects require an older version of Python. I am thinking to install this older version (v3.10) inside a virtual environment and run my project with it. But not sure how to do it.
These are the steps I followed so far:

  1. installed Python v3.12 in my PC (using Windows)

  2. installed VS code

  3. created venv with 'py -m venv .venv '

  4. activated venv with '.venv\Scripts\activate.bat '

  5. now I want to install python v3.10 in .venv. But when I ran 'py -m pip install "python==3.10.13"' it gives an error saying:

"Could not find a version that satisfies the requirement python==3.10.13 (from versions: none). No matching distribution found for python==3.10.13"

What am I doing wrong in here? am I missing anything? I looked up a video about 'PYENV' but would like to try this way. Any help much appreciated!!
Does running Python this way slow down the run times significantly?

thanks

๐ŸŒ
Medium
medium.com โ€บ itversity โ€บ setting-up-a-python-virtual-environment-and-integrating-it-with-vs-code-3080d2bfff07
Setting Up a Python Virtual Environment and Integrating It with VS Code | by Durga Gadiraju | itversity | Medium
February 10, 2025 - Ensure youโ€™re using a supported Python version (Python 3.7 or higher). Run this command in the terminal: ... Replace ASI_VENV with your desired environment name. This will create a folder named ASI_VENV in your project directory.
๐ŸŒ
TechBloat
techbloat.com โ€บ home โ€บ how to change python version in vs code
How to Change Python Version in VS Code - TechBloat
February 27, 2026 - Choose the Correct Interpreter: A list of available Python interpreters will appear. These include globally installed versions, virtual environments, and conda environments. Identify the interpreter that corresponds to the Python version you want to use.