Steps are:

  1. Click on settings icon present at bottom left of vscode screen

  2. In the top right of screen, you should see Open Settings (JSON) option

  3. In the next screen, within double quotes start typing python.p, you should start seeing all the suggestions & options available

Answer from Ujjwal Kumar Maharana on Stack Overflow
🌐
Visual Studio Code
code.visualstudio.com › docs › python › settings-reference
Python settings reference
November 3, 2021 - The Python Extension for Visual Studio Code is highly configurable. This page describes the key settings you can work with.
Discussions

Opening settings.json in VSCode - Python - Code with Mosh Forum
hey guys, I am working on the complete python mastery course. I had some trouble recently with VSCode - particularly dealing with opening a virtual environment in VSCode on Mac. In the 5th video of the “python packaging index” section, one step that the video goes over is the step of opening ... More on forum.codewithmosh.com
🌐 forum.codewithmosh.com
0
July 20, 2022
Selecting a python interpreter doesn't update settings.json
Manage -> Settings, Choose Workspace, click the button Open Settings(JSON) at the top right corner. This will generate a folder called .vscode and settings.json for workspace is there. As python environments said: Selecting an interpreter from the list adds an entry for python.pythonPath with the path to the interpreter inside your Workspace Settings . But actually, python.pythonPath setting is being removed from all 3 scopes - User, workspace, workspace folder. You can set "python.experiments.optOutFrom":["DeprecatePythonPath - experiment"] in User Settings.json to make python.pythonpath achievable again. More on reddit.com
🌐 r/vscode
4
1
March 13, 2021
Best settings.json configurations and must-have extensions?
Here is my copypasta list: Angular 17 Snippets - TypeScript, Html, Angular Material, ngRx, RxJS & F - additional snippets, always handy Angular Language Service - duh Angular Refactorizer - some easy ways to refactor some code Angular Snippets (Version 18) - more snippets, most useful ones Angular Spectator Snippets - since I use spectator for unit tests Angular Support - easily peek at component code from the template Auto Import Auto Rename Tag - easily rename the ending tag as well Batch Rename - rename multiple files in one go (I often use this for assets) Better Comments - easily see todo inside code Cline - my AI with agents (this is still better than copilot imo) Color Highlight - apply background color to a color value to show what color it is CSS Peek - peek at css properties CSS Variable Autocomplete - with tailwind very easy to see what the value will be Cucumber (Gherkin) Full Support - for my E2E tests which uses BDD - Gherkin in Playwright Document This - easily write comments for functions EditorConfig for VS Code - default editor settings around the team Error Gutters - show error icons in gutter Error Lens - show errors behind line about what is wrong ESLint - linting, use a very extended config which just autoformats my code to a standard I like to use. Improves code quality greatly Fluent Icons - nicer looking icons in the UI (not file browser) Highlight Matching Tag - default colors are a bit ugly but easily see what tag is related is just handy Highlight on Copy - flash the background for the text you copy. Makes it easy to see whether it is actually copying and that it is what you want. html-entities - easily convert html entity without looking it up HTMLHint - validate html a bit more. Just share config across team i18n Ally - preview translation strings and help adding translations Inline Parameters for VSCode - easily see what types are used for various functions so you can easily spot what you need to use or import JavaScript (ES6) code snippets - some more snippets JSON to TS - easily use an API response to build typescript interfaces Ligatures Limited - Font ligatures in VSCode make various things like !== easier to see and it just looks neat but you don't want it to replace things that shouldn't be replaced. LintLens — ESLint rules made easier - better looking popups for inspecting code. Human readable basically Markdown All in One - nice markdown tools to write it Material Icon Theme - best file icons for angular projects MDX Preview - for when you use storybook Move TS - Move TypeScript files and update relative imports - easily modify imports on files related to the file you want to move and its dependencies Multiple cursor case preserve - fantastic extension, quickly modify variable names without worrying about the upper/lowercase. Node.js Modules Intellisense - more detail about dependencies npm Intellisense - easily import items Package Json Upgrade - see what packages can be updated and click to change version Partial Diff - find differences between pieces of code quickly Path Intellisense - more path autocomplete for when you import files (like images) Playwright Test for VSCode Polacode - make neat screenshots of your code to share Prettier - Code formatter - format code though I still have most things in eslint these days Prettify JSON - easily format json to read better. Handy for debugging API calls Pretty TypeScript Errors - human readable typescript error popup Rainbow CSV - easily make css more readable Rainbow Tags - easily make tags distinguised (though default theme is trash too but it is still very nice) Rename Angular Component - easily rename without worrying about dependencies Search node_modules - quickly search node modules that are in your gitignore so this just skips opening a file browser Sort lines - sort lines quickly. Helps with readability Sort Typescript Imports - helps formatting Stylelint - lint your css styles SVG - easily preview svg and add autocomplete Tabnine: AI Chat & Autocomplete - another AI tool, fast autocomplete, faster than copilot TabOut - easily tab out of your quotes, brackets, braces Tailwind CSS IntelliSense - must have for tailwind Template String Converter - convert '' to `` when you use ${} Todo Tree - list of // TODO: stuff you used TypeScript Importer - another import thingy Vitest - my unit test tool. Beats jest and karma imo. VSCode Animations - makes vscode look cool vscode-faker - make fake data, like for testing. There's a few neat ones in there that most will probably not find and I also like to use a lot of stuff because I'm lazy, because I'm human and/or because I have high code standards. And no, my vscode performance is just fine. More on reddit.com
🌐 r/vscode
5
54
April 3, 2025
How to correctly set PYTHONPATH for Visual Studio Code - Stack Overflow
So my PYTHONPATH needs to be set to ~/project/ (something that PyCharm does automatically). VSCode is a great editor, but everywhere else, it falls short, in my opinion. This is a perfect example of that. I create a default launch.json file to "run the current file". More on stackoverflow.com
🌐 stackoverflow.com
🌐
Medium
medium.com › ordinaryindustries › the-ultimate-vs-code-setup-for-python-538026b34d94
The Ultimate VS Code Setup for Python | by Jack Fields | OrdinaryIndustries | Medium
February 18, 2025 - The Black extension can be found here. Install it as you would any other extension. Once installed, open settings.json and add these two options to your python scope.
🌐
Readthedocs
py-vscode.readthedocs.io › en › latest › files › settings.html
settings.json - How to Python in VS Code - Read the Docs
All your settings and preferences are kept in settings.json file. You can directly manipulate that file to set your preference locally or globally. Locally the settings file can be found in .vscode/settings.json folder in your current project location. To see the global settings.json, head over to $HOME/.config/Code/User/settings.json and open it in VS Code.
🌐
Visual Studio Code
code.visualstudio.com › docs › configure › settings
User and workspace settings
November 3, 2021 - In general, VS Code extensions store their settings in your user or workspaces settings files and they are available through the Settings editor UI (Preferences: Open Settings (UI) command) or via IntelliSense in your settings.json file (Preferences: Open User Settings (JSON) command). Searching by the extension name (for example gitlens or python) can help filter down settings to just those contributed by an extension.
🌐
GitHub
github.com › microsoft › vscode-python › blob › main › .vscode › settings.json
vscode-python/.vscode/settings.json at main · microsoft/vscode-python
March 8, 2022 - "out": true, // set this to false to include "out" folder in search results · "dist": true, "**/node_modules": true, "coverage": true, "languageServer*/**": true, ".vscode-test": true, ".vscode test": true · }, "[python]": { "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit", "source.organizeImports.isort": "explicit" }, "editor.defaultFormatter": "charliermarsh.ruff", }, "[rust]": { "editor.defaultFormatter": "rust-lang.rust-analyzer", "editor.formatOnSave": true ·
Author   microsoft
🌐
Code with Mosh
forum.codewithmosh.com › python
Opening settings.json in VSCode - Python - Code with Mosh Forum
July 20, 2022 - hey guys, I am working on the complete python mastery course. I had some trouble recently with VSCode - particularly dealing with opening a virtual environment in VSCode on Mac. In the 5th video of the “python packaging index” section, one step that the video goes over is the step of opening the Settings.json file.
Find elsewhere
🌐
Visual Studio Code
code.visualstudio.com › docs › python › environments
Python environments in VS Code
November 3, 2021 - To use a different interpreter for debugging, set the python property in your launch.json debug configuration. 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: Workspace-local virtual environments (.venv, venv) ... To override this priority order, set python-envs.defaultEnvManager to prefer a specific manager (for example, ms-python.python:conda), or configure Python Projects for per-folder control.
🌐
GeeksforGeeks
geeksforgeeks.org › python › locating-and-modifying-vscode-settingsjson
Locating and Modifying VSCode settings.json - GeeksforGeeks
August 28, 2024 - Examples · Quizzes · DSA Python · Data Science · NumPy · Pandas · Practice · Django · Flask · Last Updated : 28 Aug, 2024 · Visual Studio Code (VSCode) is a popular code editor known for its customizability. This customizability is mainly due to the settings.json file, where we can configure the editor to our preferences.
🌐
Visual Studio Code
code.visualstudio.com › docs › python › formatting
Formatting Python in VS Code
November 3, 2021 - Alternatively, you can set it as the default formatter for all Python files by setting "editor.defaultFormatter" in your User settings.json file, under a [python] scope. You can open settings.json with the Preferences: Open User Settings (JSON) command. For example, to set Black Formatter as the default formatter, add the following setting to your User settings.json file:
🌐
GitHub
gist.github.com › c2a0441e63928ca7bdbf7db2a22d4f1e
Visual Studio Code Settings.json file for Python development ( Using Don Jayamanne's Python Extension) · GitHub
Visual Studio Code Settings.json file for Python development ( Using Don Jayamanne's Python Extension) - settings.json
🌐
Reddit
reddit.com › r/vscode › selecting a python interpreter doesn't update settings.json
r/vscode on Reddit: Selecting a python interpreter doesn't update settings.json
March 13, 2021 -

I open a folder in vscode, this folder does not have a settings.json and I run ctrl + shift p, and select an interpreter. This does not create a settings.json file and add settings to it.

I have also tried opening file -> settings, editing workspace settings so I have a settings.json and selecting interpreter but still nothing is added.

I have also tried creating a ${folder}.code-workspace settings file and selecting interpreter but nothing is added.

How do I make my folder a valid workspace so I can select an interpreter and the settings.json will update?

🌐
Reddit
reddit.com › r/vscode › best settings.json configurations and must-have extensions?
r/vscode on Reddit: Best settings.json configurations and must-have extensions?
April 3, 2025 -

Hey everyone,

I’ve been using VS Code for a while, but I feel like I’m not taking full advantage of its customization options. I want to optimize my setup, so I’m looking for recommendations on:

  1. Best settings.json configurations – What tweaks have significantly improved your workflow, performance, or overall experience?

  2. Must-have extensions – Which extensions do you consider essential for productivity, debugging, or specific workflows?

I mostly work with TypeScript, JavaScript, React, Next.js, Node.js, Express, NestJS, Python, C++, .NET, and React Native, so any suggestions to those would be great. But I’m also open to general improvements that could benefit any workflow.

Would love to see what works for you all. Thanks!

Thanks in advance!

Top answer
1 of 5
41
Here is my copypasta list: Angular 17 Snippets - TypeScript, Html, Angular Material, ngRx, RxJS & F - additional snippets, always handy Angular Language Service - duh Angular Refactorizer - some easy ways to refactor some code Angular Snippets (Version 18) - more snippets, most useful ones Angular Spectator Snippets - since I use spectator for unit tests Angular Support - easily peek at component code from the template Auto Import Auto Rename Tag - easily rename the ending tag as well Batch Rename - rename multiple files in one go (I often use this for assets) Better Comments - easily see todo inside code Cline - my AI with agents (this is still better than copilot imo) Color Highlight - apply background color to a color value to show what color it is CSS Peek - peek at css properties CSS Variable Autocomplete - with tailwind very easy to see what the value will be Cucumber (Gherkin) Full Support - for my E2E tests which uses BDD - Gherkin in Playwright Document This - easily write comments for functions EditorConfig for VS Code - default editor settings around the team Error Gutters - show error icons in gutter Error Lens - show errors behind line about what is wrong ESLint - linting, use a very extended config which just autoformats my code to a standard I like to use. Improves code quality greatly Fluent Icons - nicer looking icons in the UI (not file browser) Highlight Matching Tag - default colors are a bit ugly but easily see what tag is related is just handy Highlight on Copy - flash the background for the text you copy. Makes it easy to see whether it is actually copying and that it is what you want. html-entities - easily convert html entity without looking it up HTMLHint - validate html a bit more. Just share config across team i18n Ally - preview translation strings and help adding translations Inline Parameters for VSCode - easily see what types are used for various functions so you can easily spot what you need to use or import JavaScript (ES6) code snippets - some more snippets JSON to TS - easily use an API response to build typescript interfaces Ligatures Limited - Font ligatures in VSCode make various things like !== easier to see and it just looks neat but you don't want it to replace things that shouldn't be replaced. LintLens — ESLint rules made easier - better looking popups for inspecting code. Human readable basically Markdown All in One - nice markdown tools to write it Material Icon Theme - best file icons for angular projects MDX Preview - for when you use storybook Move TS - Move TypeScript files and update relative imports - easily modify imports on files related to the file you want to move and its dependencies Multiple cursor case preserve - fantastic extension, quickly modify variable names without worrying about the upper/lowercase. Node.js Modules Intellisense - more detail about dependencies npm Intellisense - easily import items Package Json Upgrade - see what packages can be updated and click to change version Partial Diff - find differences between pieces of code quickly Path Intellisense - more path autocomplete for when you import files (like images) Playwright Test for VSCode Polacode - make neat screenshots of your code to share Prettier - Code formatter - format code though I still have most things in eslint these days Prettify JSON - easily format json to read better. Handy for debugging API calls Pretty TypeScript Errors - human readable typescript error popup Rainbow CSV - easily make css more readable Rainbow Tags - easily make tags distinguised (though default theme is trash too but it is still very nice) Rename Angular Component - easily rename without worrying about dependencies Search node_modules - quickly search node modules that are in your gitignore so this just skips opening a file browser Sort lines - sort lines quickly. Helps with readability Sort Typescript Imports - helps formatting Stylelint - lint your css styles SVG - easily preview svg and add autocomplete Tabnine: AI Chat & Autocomplete - another AI tool, fast autocomplete, faster than copilot TabOut - easily tab out of your quotes, brackets, braces Tailwind CSS IntelliSense - must have for tailwind Template String Converter - convert '' to `` when you use ${} Todo Tree - list of // TODO: stuff you used TypeScript Importer - another import thingy Vitest - my unit test tool. Beats jest and karma imo. VSCode Animations - makes vscode look cool vscode-faker - make fake data, like for testing. There's a few neat ones in there that most will probably not find and I also like to use a lot of stuff because I'm lazy, because I'm human and/or because I have high code standards. And no, my vscode performance is just fine.
2 of 5
16
I like an extension called Auto Hide (VS Marketplace Id: sirmspencer.vscode-autohide) combined with the following settings: "workbench.sideBar.location": "right" "autoHide.panelDelay": 1 "autoHide.sideBarDelay": 1 It puts the sidebar on the right and hides it when you click in the editor.
🌐
Steve Kinney
stevekinney.com › courses › visual studio code › editing settings through json
Editing Settings Through JSON | Visual Studio Code | Steve Kinney
March 16, 2026 - For example: { "[python]": { "editor.tabSize": 4, "editor.insertSpaces": true, "python.linting.pylintEnabled": true }, "[javascript]": { "editor.tabSize": 2, "editor.insertSpaces": true } } This example sets tabSize to 4 and enables pylint for ...
🌐
Medium
medium.com › @carmelle.m › example-settings-json-for-vs-code-cb2324ac2519
Example settings.json for VS Code | by Carmelle M. | Medium
August 5, 2020 - Example settings.json for VS Code While you’re here, check out my YouTube tutorial for three vscode extensions you need for web development! This settings.json file assumes you have installed …
🌐
Donjayamanne
donjayamanne.github.io › pythonVSCodeDocs › docs › python-path
Python Path and Version | Python in Visual Studio Code
If a specific version is to be used, then configure the path to the python interpreter in the User or Workspace Settings file (settings.json) as follows.
🌐
Visual Studio Code
code.visualstudio.com › docs › python › debugging
Python debugging in VS Code
November 3, 2021 - By default, the debugger uses the same interpreter selected for your workspace, just like other features of Python extension for VS Code. To use a different interpreter for debugging specifically, set the value for python in launch.json for the applicable debugger configuration.
Top answer
1 of 16
182

I have a situation that I believe is relatively common. I want a script to import a module from another directory. My python project is laid out as follows:

~/project/
  |
  |---modules/
        |
        |---mod.py
  |---scripts/
        |---script.py

in script.py, I have from modules import mod. So my PYTHONPATH needs to be set to ~/project/ (something that PyCharm does automatically).

VSCode is a great editor, but everywhere else, it falls short, in my opinion. This is a perfect example of that.

I create a default launch.json file to "run the current file". A "cwd": "${fileDirname}" line has to be added to make things work like they do in PyCharm (FYI, a list of the built-in variables can be found here).

Debugging

For debugging (the "play" button on the sidebar, or the F5 key), the PYTHONPATH set in launch.json or your .env file takes effect. Note that in the .env file, you cannot use variables such as ${workspaceRoot}, but you can easily append or insert to the path by using the proper separator for your platform (; for Windows and : for everyone else).

Because I want to take advantage of that variable, I put this in my launch.json:

    "env": {"PYTHONPATH": "${workspaceFolder}${pathSeparator}${env:PYTHONPATH}"}

(Thanks to @someonr for the suggestion to use ${pathSeparator}.)

It appears that you can prepend/append to whatever is inherited from the environment (this is not true for settings.json; see below).

This will also work for the hotkey Ctrl+F5 (run without debugging).

For reference, here's the full file, which replicates what PyCharm does automatically:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "cwd": "${fileDirname}",
            "env": {"PYTHONPATH": "${workspaceFolder}${pathSeparator}${env:PYTHONPATH}"}
        }
    ]
}

Run in terminal

If I hit the "play" button that appears on the top right of the editor window (when a python file is the active tab), it will not work. This runs the current file in a terminal, which doesn't pay attention to launch.json at all. To make that work, you have to define PYTHONPATH in a settings.json file, by adding this:

    "terminal.integrated.env.osx": {"PYTHONPATH": "${workspaceFolder}"}

(Note there are different values for each platform.) If you've selected a python interpreter (e.g. from a virtual environment), you will already have a settings.json file in the .vscode directory. Mine looks like this:

{
    "python.pythonPath": "/Users/me/project/venv/bin/python3",
    "terminal.integrated.env.osx": {"PYTHONPATH": "${workspaceFolder}"}
}

You can't append or insert values into the inherited PYTHONPATH via the settings.json file. It will only take one string, and it will not parse separators. So even though you could get the value using ${env:PYTHONPATH}, you won't be able to do anything with it.

Moreover, you can't set the current working directory. Even though it would seem you could set it with "terminal.integrated.cwd": "${workspaceFolder}", it doesn't work. So if any of your scripts do anything with paths relative to their location in the tree, they won't work. The working directory will be your project root.

Note that any changes to the settings.json file will require that you exit the integrated terminal and restart it.

Linting

Nothing I do to launch.json regarding PYTHONPATH makes any difference to pylint, which will red-underline from modules import mod, despite the fact I can put the cursor on mod, hit F12, and the file opens. Snooping around linting settings, the defaults for mypy include --ignore-missing-imports. To replicate this behavior with pylint, add this to your settings.json:

    "python.linting.pylintArgs": [
        "--disable=F0401"
    ] 

Shame that we just have to work around this, but the autocomplete helps a lot when writing the import statements to begin with.

Conclusion

There are many layers to VSCode and it's hard to get things to work together. It seems multiple environments are floating around. In the end:

  1. I cannot "run in terminal" because I can't set the current working directory to be the path containing the current file.
  2. I cannot set PYTHONPATH for pylint as that runs in some environment different than the integrated terminal and whatever is controlled by launch.json, so I can only tell pylint to ignore import errors.
  3. Running with F5 works if you set PYTHONPATH either via an .env file or in launch.json
2 of 16
60

The documentation is missing some important details.

Example

Suppose your project layout is like this

myproject/
    .vscode/
        settings.json
    .env
    src/
        a_module.py
    tests/
        test_a.py

Open the settings.json file and insert these lines

// On linux use "terminal.integrated.env.linux": {
"terminal.integrated.env.windows": {
    "PYTHONPATH": "${workspaceFolder}/src;${workspaceFolder}/tests"
},
// The next line can be omitted, unless you've modified the global default
"python.envFile": "${workspaceFolder}/.env",

Note that ${workspaceFolder} evaluates to myproject, it is not to the .vscode folder.

In the .env file enter this

PYTHONPATH=src;test
# Paths are relative to the workspace folder, so above is equivalent to
# WORKSPACE_FOLDER=C:/full/path/to/myproject
# PYTHONPATH=${WORKSPACE_FOLDER}/src;${WORKSPACE_FOLDER}/tests

Note that on all platforms, including Windows, the slashes in the path lean forward, like so /. Different paths are separated with a ; on Windows, on other platforms with a :.

Final step, restart VS Code.

This blog was helpful.

🌐
Orchestra
getorchestra.io › guides › using-os-environ-with-local-settings-in-vs-code-settings-json
Using os.environ with Local Settings in VS Code settings.json | Orchestra
March 22, 2025 - Unfortunately, VS Code does not directly support environment variables within settings.json. However, a common workaround is to store environment variable values in a separate .env file and reference them in Python code using os.environ.