If you want to install a package into your specific virtual environment, you need to first "activate" that environment. Likewise, if you want to run your script in that environment, you need to first "activate" it. You can do this manually or preferably let VSCode handle it for you.

In order to tell VSCode(especially the language server which is pylance) to use that environment:

  1. Open up your Command Palette(press ctrl+shift+P or f1) and type : "python: select interpreter".
  2. Browse/Select your newly created python interpreter's path inside your venv.
  3. Add "python.terminal.activateEnvironment": true to your setting.json file(It's also possible via GUI setting of course by searching for python: activate environment). This will automatically detect and activate your venv whenever you open your integrated terminal. Obviously If the path should points to a venv interpreter. (Note: you have to have a Python file opened in your editor).

You can also set your Python's interpreter path manually:

  1. Create a folder called .vscode in your workspace.
  2. Create a file called settings.json inside it.
  3. Add these to settings.json:
{
    "python.defaultInterpreterPath": "PATH_TO_VENV_INTERPRETER",
    "python.terminal.activateEnvironment": true
}

Note: What I normally do is, I insert a "python.defaultInterpreterPath" key to my User settings.json which points to my global interpreter. Then I create Workspace settings.json for each of my projects and add the same key which points to my venv's interpreter. Remember, workspace settings.json will overwrite user's settings.json.

This way whenever you open VSCode in a project folder it automatically knows it should activate your venv's interpreter(I told it to do so with "python.terminal.activateEnvironment") and if you open VSCode in a normal folder it correctly use your global's interpreter.

Difference between User and Workspace settings.json.

Answer from S.B on Stack Overflow
🌐
Visual Studio Code
code.visualstudio.com › docs › python › settings-reference
Python settings reference
November 3, 2021 - Note: If you have never changed your language server setting, your language server is set to Pylance via the “Default” setting value.
🌐
Readthedocs
micropython-stubs.readthedocs.io › en › main › 22_vscode.html
Configuring VSCode, Pylance or Pyright — Micropython-Stubs 1.23.0 documentation
Note: If you’ve previously set a language server and want to try Pylance, make sure you’ve set "python.languageServer": "Default" or "Pylance" in your settings.json file using the text editor, or using the Settings Editor UI. ... If you have created a .venv make sure to also select it in VSCode using F1, >Python: select interpreter or the UX
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
Pylance - Visual Studio Marketplace
2 weeks ago - Extension for Visual Studio Code - A performant, feature-rich language server for Python in VS Code
Top answer
1 of 2
31

If you want to install a package into your specific virtual environment, you need to first "activate" that environment. Likewise, if you want to run your script in that environment, you need to first "activate" it. You can do this manually or preferably let VSCode handle it for you.

In order to tell VSCode(especially the language server which is pylance) to use that environment:

  1. Open up your Command Palette(press ctrl+shift+P or f1) and type : "python: select interpreter".
  2. Browse/Select your newly created python interpreter's path inside your venv.
  3. Add "python.terminal.activateEnvironment": true to your setting.json file(It's also possible via GUI setting of course by searching for python: activate environment). This will automatically detect and activate your venv whenever you open your integrated terminal. Obviously If the path should points to a venv interpreter. (Note: you have to have a Python file opened in your editor).

You can also set your Python's interpreter path manually:

  1. Create a folder called .vscode in your workspace.
  2. Create a file called settings.json inside it.
  3. Add these to settings.json:
{
    "python.defaultInterpreterPath": "PATH_TO_VENV_INTERPRETER",
    "python.terminal.activateEnvironment": true
}

Note: What I normally do is, I insert a "python.defaultInterpreterPath" key to my User settings.json which points to my global interpreter. Then I create Workspace settings.json for each of my projects and add the same key which points to my venv's interpreter. Remember, workspace settings.json will overwrite user's settings.json.

This way whenever you open VSCode in a project folder it automatically knows it should activate your venv's interpreter(I told it to do so with "python.terminal.activateEnvironment") and if you open VSCode in a normal folder it correctly use your global's interpreter.

Difference between User and Workspace settings.json.

2 of 2
6

Please select the appropriate interpreter for your running environment.

ctrl+shift+P

and then choose the one like picture.

🌐
Visual Studio Magazine
visualstudiomagazine.com › articles › 2025 › 01 › 09 › vs-code-python-devs-get-full-language-server-mode-for-pylance.aspx
VS Code Python Devs Get 'Full' Language Server Mode for Pylance -- Visual Studio Magazine
January 9, 2025 - "Designed to integrate seamlessly with your preferred environment managers via various APIs, it supports Global Python interpreters, venv, and Conda out of the box," the team said. "Developers can build extensions to add support for their favorite Python environment managers and integrate with our extension UI, enhancing functionality and user experience." Finally, the team announced new Docstring generation features using Pylance and Copilot, which provides a new way to generate docstrings for Python functions, serving to document the purpose and usage of the code they describe.
🌐
GitHub
github.com › microsoft › vscode-python › issues › 25301
Python extension not starting Pylance · Issue #25301 · microsoft/vscode-python
July 17, 2025 - I am trying to use python on the newest VS Code version on my macbook and no matter what I do the Pylance Intellisense isnt working. When I hover over methods it doesn't show anything and there is no suggestions for methods to use. I hav...
Author   andrew-dragoslavic
🌐
Visual Studio Magazine
visualstudiomagazine.com › articles › 2021 › 05 › 11 › vscode-python-may21.aspx
Pylance Now Default Language Server for Python in Visual Studio Code -- Visual Studio Magazine
May 11, 2021 - No such language server is more important to VS Coders than Pylance, as it is now bundled as an optional offering with the core Python extension that has been installed a whopping 35.5 million times, way more than any other tool.
Find elsewhere
🌐
Medium
medium.com › lanavajasuiza-tech › part-4-configuring-pylance-in-vs-code-to-recognise-your-python-libraries-d58ae642712a
Part 4: Configuring Pylance in VS Code to Recognise Your Python Libraries | by Ana Ndongo | lanavajasuiza.tech | Medium
November 29, 2025 - Pylance is a powerful extension for working with Python in VS Code, but sometimes it acts like a drama queen: red squiggles everywhere, vague warnings, and general chaos. If you’ve ever seen “Import…
🌐
Microsoft Learn
learn.microsoft.com › en-us › shows › vs-code-livestreams › pylance-new-and-improved-python-experience
Pylance: our new and improved Python experience in VS Code | Microsoft Learn
May 13, 2021 - Get a glimpse of the most performant and user-friendly editing experience for Python in VS Code ever. The newest version of the extension dramatically improves language support via our new language server, Pylance.
🌐
GitHub
github.com › microsoft › pylance-release › issues › 330
How can I set pylance to use virtual python environment · Issue #330 · microsoft/pylance-release
September 6, 2020 - I wonder how can I set pylance to use a virtual python environment, for example, the python interpreter and libs in venv folder. I try to change the python interpreter in vscode, but it seems pylance will not change. And it leads to the problem of missing packages.
Author   jameslahm
🌐
DEV Community
dev.to › climentea › how-to-solve-pylance-missing-imports-in-vscode-359b
How to solve Pylance 'missing imports' in vscode - DEV Community
February 3, 2021 - A folder named .vscode will be created once you select a different interpreter than the default one. Inside .vscode you will have a settings.json file. In settings.json file you have to add the paths from which you import what's needed in extraPaths: { "python.pythonPath": "/home/youruser/.virtualenvs/app-FzQGSFjf/bin/python", "python.analysis.extraPaths": ["app", "another/path/etc"] } In my case, app folder was not known by Pylance.
🌐
Hrekov
hrekov.com › blog › pylance-reportmissingimports-vs-code
Resolving Pylance(reportMissingImports) in VS Code | Backend APIs, Web Apps, Bots & Automation | Hrekov
February 19, 2026 - Go to Solution 1: Return to Solution 1 and select the newly created .venv interpreter in VS Code. If the basic fix doesn't work, Pylance might be ignoring the VS Code settings, or you might be in a non-standard setup. Sometimes, Pylance needs its path explicitly set in the workspace settings (.vscode/settings.json).
🌐
Microsoft Developer Blogs
devblogs.microsoft.com › dev blogs › microsoft for python developers blog › python in visual studio code – june 2022 release
Python in Visual Studio Code – June 2022 Release - Microsoft for Python Developers Blog
June 9, 2022 - This release includes improvements to: Localization support Python interpreter discovery Jupyter extension support on vscode.dev/github.dev Insiders program for Pylance If you’re interested, you can check the full list of improvements in our changelogs […]
🌐
Medium
medium.com › @prathik.codes › 4-great-pylance-tips-for-vs-code-e0c5f44c7435
4 Great Pylance Tips for VS Code. Python Quickies #2 | by Prathik C | Medium
November 14, 2024 - One such extension that is extremely popular with python developers using VS Code is Pylance. It provides great enhancement for python extension in Code including intellisense, type checking, etc. If you are not already using it, go install it!
🌐
Microsoft Developer Blogs
devblogs.microsoft.com › dev blogs › microsoft for python developers blog › python in visual studio code – july 2021 release
Python in Visual Studio Code – July 2021 Release - Microsoft for Python Developers Blog
July 20, 2021 - We're excited to announce the July 2021 release of the Python extension for VS Code! This release includes a faster way to configure project roots via a new Pylance quick fix, two new debugger features and Python interpreter settings changes. Keep on reading to learn more!
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 5594952 › issue-with-the-interpreter-in-visual-studio-code
Issue with the interpreter in Visual Studio Code - Microsoft Q&A
October 23, 2025 - In Visual Studio Code, the specific function you need to check is called "Python: Select Interpreter". You can find it by pressing Ctrl+Shift+P (or Cmd+Shift+P on Mac), then typing "Python: Select Interpreter" in the command palette.
🌐
Learnscript
learnscript.net › en › python › development-tools › vscode › pylance
VSCode Pylance Extension Usage and Setup Instructions - Python Tutorial | Learn
June 15, 2024 - The Pylance extension in VSCode provides powerful support for Python language development, such as smart hints, completions, diagnostics and analysis of code. In general, this extension will be installed with VSCode's Python extension and will be the Python language server recognized by the ...