microsoft / vscode-python-debugger

Python debugger (debugpy) extension for VS Code.
https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy
MIT License
41 stars 17 forks source link

os.environ misses my variable in the debugger #293

Open duaneellissd opened 3 months ago

duaneellissd commented 3 months ago

I have a windows batch file, it does the following:

a) step 1: creates an ENV variable - ie, the statement: set FOOBAR=12345678 WINDOWS does not use an export statement like LINUX uses. so My thinking {which is probably wrong) is that it should be in the environment.

b) step 2 - Launches VS CODE My "FOOBAR" variable should be present - I would think

c) Run python and example: "os.environ" - ie Print the environment.

QUESTION: What happened to my variable: "FOOBAR"

karthiknadig commented 3 months ago

@duaneellissd Are you setting this and then launching VS Code from that terminal or are you using this in debug configuration?

If you are using the terminal method then this is what you should be doing:

You can verify this from inside VS Code by opening any terminal and running set FOOBAR.

image

Running in terminal: image

Running via debugger: image