You have three methods to configure PYTHONPATH:
1.terminal.integrated.env.* in the settings.json file. For example:
"terminal.integrated.env.windows": {
"PYTHONPATH": "${workspaceFolder}"
}
But it only affects the actions routed through the terminal such as debugging.
When the terminal settings are used, PYTHONPATH affects any tools that
are run within the terminal by a user, as well as any action the
extension performs for a user that is routed through the terminal such
as debugging. However, in this case when the extension is performing
an action that isn't routed through the terminal, such as the use of a
linter or formatter, then this setting will not have an effect on
module look-up.
2.Configure PYTHONPATH in .env file:
By default, the Python extension looks for and loads a file named .env
in the current workspace folder. The file is identified by the default
entry "python.envFile": "${workspaceFolder}/.env" in your user
settings.
But it will not affect the actions run in the terminal.
When PYTHONPATH is set using an .env file, it will affect anything the
extension does on your behalf and actions performed by the debugger,
but it will not affect tools run in the terminal.
3.Configure the "env" entry in the launch.json file, such as:
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"envFile": "${workspaceFolder}/.env",
"env": {
"PYTHONPATH": "${workspaceFolder}"
}
}
Obviously, It only affects the debugging actions.