Repository navigation
[BUG] VS Code python.envFile does not seem to work with python.defaultInterpreterPath #19276
Description
Discussed in #19275
Originally posted by sugatoray June 10, 2022
Despite specifying a python.envFile in workspace (.vscode/settings.json), python.defaultInterpreterPath does not seem to fetch the interpreter path via an environment variable, declared in the envFile.
# filename: .env
# set this in .vscode/settings.json:
# "python.envFile": "${workspaceFolder}/.env"
DEFAULT_INTERPRETER_PATH=path/to/python/interepreter// filename: .vscode/settings.json
{
"python.envFile": "${workspaceFolder}/.env",
"python.defaultInterpreterPath": "${env:DEFAULT_INTERPRETER_PATH}",
"python.terminal.activateEnvironment": true,
"python.terminal.activateEnvInCurrentTerminal": false,
"jupyter.jupyterServerType": "local",
}If I hard code the python.defaultInterpreterPath, it works, and auto activates the interpreter, when I open a new terminal window. But it does not activate the the interpreter from the variable (in .env file).
References
- https://code.visualstudio.com/docs/python/environments#_environment-variables
- https://stackoverflow.com/questions/56178143/in-vs-code-debugger-how-do-i-use-envfile-in-launch-json-for-nodejs
- https://www.youtube.com/watch?v=qTU7w3bWrOk&ab_channel=JonathanSoma
- This says you can only use the env variables from the
.envfile if you are debugging: https://www.reddit.com/r/vscode/comments/tkwooh/run_not_debug_python_using_the_env_file/ - .env file not working on run current file action #11174
🔥 Note
I have raised this as a question on stackoverflow already.
Does this issue occur when all extensions are disabled?: Yes/No
I have not and can't afford to check that as I don't know a programmatic way of restoring current extensions state.
Diagnostics Info:
Version: 1.67.2
Commit: c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5
Date: 2022-05-17T18:23:40.286Z
Electron: 17.4.1
Chromium: 98.0.4758.141
Node.js: 16.13.0
V8: 9.8.177.13-electron.0
OS: Linux x64 5.13.0-44-generic snapSteps to Reproduce:
Follow the description given above.
💡 I have opened another issue here:
I was told to contact with vscode-python by the vscode team.
Activity
[-]VS Code `python.envFile` does not seem to work with `python.defaultInterpreterPath`[/-][+][BUG] VS Code `python.envFile` does not seem to work with `python.defaultInterpreterPath`[/+]brettcannon commentedon Jun 13, 2022
Closing in favour of the original Discussion post.