Debug Python3 in venv doesn't return exported environment vars

I am trying to debug a Python3 script that is running in a virtual environment. Based on advice on an earlier question, I set up a project and pointed the debugger at the interpreter in my venv folder.

This is running a Google Translate job that requires exporting a couple of variables to the environment. So I invoke the venv and export those variables, and ensure that I can see them with printenv.

I also wrote a test script:

from os import environ
project_id = environ.get(“PROJECT_ID”, “”)
print(project_id)

And it prints the project id as it should.

But when I run the same test script in the debugger, the exported project id is not in the environment variables and isn’t printed. Any idea what is going on?

Morning @DryHeat122,

My guess is that you didn’t start Komodo from the terminal window where you have those variables defined. I’d need to know what OS you’re on to give you specific help. You’d either need to:

  1. Start Komodo from that terminal
  2. Add the variable globally to your system so all programs can see it
  3. Add the variable to Komodo Preferences > Environment.
  • Carey

That was it. I started Komodo from the venv terminal and it worked. Thanks.

1 Like