.env file is not reloaded/interpolated
See original GitHub issueApplies To
- Notebooks (.ipynb files)
- Interactive Window and/or Cell Scripts (.py files with #%% markers)
What happened?
I’ve been trying to add some additional search paths to PYTHONPATH, so I created an env file
PYTHONPATH='lib:crawler:api:${env:PYTHONPATH}'
There are a few problems:
- The variable was never interpolated, e.g. the output of
sys.path
is:
['/Users/janrito/path/to/project',
'/Users/janrito/path/to/project/notebooks',
'/Users/janrito/path/to/project/notebooks/lib',
'/Users/janrito/path/to/project/notebooks/crawler',
'/Users/janrito/path/to/project/notebooks/api',
'/Users/janrito/path/to/project/notebooks/${env',
'/Users/janrito/path/to/project/notebooks/PYTHONPATH}',
'/opt/homebrew/Caskroom/miniforge/base/envs/project-env/lib/python39.zip',
'/opt/homebrew/Caskroom/miniforge/base/envs/project-env/lib/python3.9',
...
]
-
I cannot reload the environment variables. I’ve tried restarting the kernel, the language server, vscode itself - with no success. I deleted the .env file
sys.path
remains the same -
The path relative root is wrong:
In .vscode/settings.json
I have set:
"jupyter.notebookFileRoot": "${workspaceFolder}",
The additional search paths should have been added relative to the project root, not relative to the notebooks directory.
VS Code Version
Version: 1.66.0-insider
Jupyter Extension Version
v2022.3.1000851004
Jupyter logs
No response
Coding Language and Runtime Version
Python v3.9.10 from miniconda
Language Extension Version (if applicable)
v2022.3.10831003
Anaconda Version (if applicable)
mamba 0.22.1 conda 4.12.0
Running Jupyter locally or remotely?
Local
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Interpolate Environment Variables using Config::Any and the ...
As I understand it, -InterPolateEnv => 1 by itself does not trigger the loading of that module. It is an option which that...
Read more >Configuration | Prefect Docs
Prefect's settings are stored in a configuration file called config.toml . In general, you should not edit this file directly to modify Prefect's...
Read more >Property Interpolation — GeoServer 2.23.x User Manual
GeoServer app-schema supports the interpolation of properties (the Java equivalent of environment variables) into app-schema mapping files.
Read more >python-dotenv - PyPI
Read key-value pairs from a .env file and set them as environment variables. ... Python-dotenv can interpolate variables using POSIX variable expansion.
Read more >Environment variables in Compose | Docker Documentation
The .env file feature only works when you use the docker-compose up command and does not work with docker stack deploy . Both...
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 FreeTop 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
Top GitHub Comments
to be clear, .env files area supported, but not replacing tokens such as
${env:PYTHONPATH}
with something else. Jupiter extension is not specific to just python, apples to R, julia, etc, hence not sure about the tokens used in env files, i think this is specific to python.once again, we’ll focus this within the team and we’ll update this issue accordingly
Any solution to this? I met the same issue/bug. It never updates the env variable even after restarting everything. Vscode 1.66.2, vscode-jupyter v2022.3.1000901801