'Using environment variables with VSCode Jupyter

I'm trying to use Jupyter Notebooks in VSCode. The notebook will not access my environment variables I have set on MacOS. I'm not able to find any solutions in my searches. Any help?

Edit: os.getenv returns None for my variable.



Solution 1:[1]

Do you get it like this?

import os
value = os.getenv('OneDrive')
print(value)

Does it work in the python script?

And please check whether you have modified it in the .env file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Steven-MSFT