You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Value of the python.languageServer setting: Microsoft
Expected behaviour
When clicking the green "Play" button on the top right of the editor window I expect the current python file to be executed and the .env file in the workspace to be loaded adding the environment variables in that file to the environment where python executes the file.
Actual behaviour
.env file doesn't seem to be loaded because the expected environment variables are not available in the python script
Steps to reproduce:
Create a folder
Open the folder in VScode
Create a .env file with the contents:
VARIABLE=testing
Create a test.py file with the contents:
import os
print(os.environ['VARIABLE'])
Click the green "Play" button on the top right corner of the editor window
/Volumes/git/env_bug
02:29 $ /usr/local/bin/python3 /Volumes/git/env_bug/test.py
Traceback (most recent call last):
File "/Volumes/git/env_bug/test.py", line 2, in <module>
print(os.environ['VARIABLE'])
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/os.py", line 681, in __getitem__
raise KeyError(key) from None
KeyError: 'VARIABLE'
Output from Console under the Developer Tools panel:
[Extension Host] Info Python Extension: 2020-04-15 08:48:39: Cached data exists getEnvironmentVariables, /Volumes/git/env_bug
console.ts:137 [Extension Host] Info Python Extension: 2020-04-15 08:48:39: Cached data exists getEnvironmentVariables, extension-output-#4
console.ts:137 [Extension Host] Info Python Extension: 2020-04-15 08:48:51: Cached data exists getEnvironmentVariables, /Volumes/git/env_bug
console.ts:137 [Extension Host] Info Python Extension: 2020-04-15 08:48:54: Cached data exists getEnvironmentVariables, extension-output-#4
console.ts:137 [Extension Host] Info Python Extension: 2020-04-15 08:49:04: Cached data exists getEnvironmentVariables, /Volumes/git/env_bug
console.ts:137 [Extension Host] Info Python Extension: 2020-04-15 08:49:04: Cached data exists getEnvironmentVariables, extension-output-#5
console.ts:137 [Extension Host] Info Python Extension: 2020-04-15 08:49:06: Cached data exists getEnvironmentVariables, /Volumes/git/env_bug
console.ts:137 [Extension Host] Info Python Extension: 2020-04-15 08:49:06: Cached data exists getEnvironmentVariables, extension-output-#9
console.ts:137 [Extension Host] Info Python Extension: 2020-04-15 08:49:16: Cached data exists getEnvironmentVariables, /Volumes/git/env_bug
console.ts:137 [Extension Host] Info Python Extension: 2020-04-15 08:49:20: Cached data exists getEnvironmentVariables, extension-output-#9
If instead I run the same file with the debugger I get the expected result
Environment data
"python.jediEnabled"set to; more info How to update the language server to the latest stable version #3977): jedi == Falsepython.languageServersetting: MicrosoftExpected behaviour
When clicking the green "Play" button on the top right of the editor window I expect the current python file to be executed and the .env file in the workspace to be loaded adding the environment variables in that file to the environment where python executes the file.
Actual behaviour
.env file doesn't seem to be loaded because the expected environment variables are not available in the python script
Steps to reproduce:
Output from
Consoleunder theDeveloper Toolspanel:If instead I run the same file with the debugger I get the expected result
I have already read all the discussion on #944 and I don't think it's the same. I observe the same as #9358 which I think was closed down prematurely.