Environment Variable `${env:HOME}` not being recognized in `.env` file when setting PYTHONPATH
See original GitHub issueDoes this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.68.1
- OS Version: Ubuntu 20.04
Steps to Reproduce:
mkdir python-test && cd python-test
echo "import a" >> main.py
echo "PYTHONPATH=\$HOME/python-test/external" >> .env
mkdir external && cd external
touch a.so
open python-test
folder with vscode, click main.py
, click F5, we get an error
Exception has occurred: ModuleNotFoundError
No module named 'a'
However, if I update .env
to PYTHONPATH=/home/jasjuang/python-test/external
, I get the expected error
Exception has occurred: ImportError
/home/jasjuang/python-test/external/a.so: file too short
This seems to indicate that vscode is unable to parse the environment variable $HOME
in the .env
file correctly. I also observe the same problem on macOS, where vscode is unable to parse the environment variable $USER
in the .env
file correctly.
Is it possible to fix it so that the environment variables are parsed correctly? It would be nice to be able to share the .env
file among different machines.
Issue Analytics
- State:
- Created a year ago
- Comments:14
Top Results From Across the Web
Why is ${env:VARNAME} in my VS Code .env file not being ...
I have defined a system environment variable: HOME=d: In my VS CODE .env file, I define a new variable: pythonpath=${env:HOME}\foo.
Read more >Understanding the Python Path Environment Variable in Python
Python path is an environment variable used to maintain directories of custom Python libraries. Learn how to set a python path variable on ......
Read more >Frequently Asked Questions — Ansible Documentation
Setting environment variables can be done with the environment keyword. ... Start of python fails with The module libpython2.7.so was not found.
Read more >Env vars - Dynaconf - 3.1.11
Environment Variables ¶. Dynaconf prioritizes environment variables over files as the best recommendation to keep your settings.
Read more >Using .env Files for Environment Variables in Python ...
If an environment variable is not found in the .env file, ... Docker will then set the same environment variables you've been using...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@karrtikr @karthiknadig this doesn’t really seem related to
debugpy
(the management of environment variables is not really done at the debugger, rather, it’s done invscode-python
which launches the debugger).Sorry for all the confusion, debugger doesn’t work due to a bug https://github.com/microsoft/vscode-python/issues/18572. But other features should ideally be working. You can verify this:
python.logging.level
todebug
in User settings, and install the pre-release version of the extension:Dump environment variables
where you can seePYTHONPATH
should be printed as you expect.Closing as dup of https://github.com/microsoft/vscode-python/issues/18572