-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect PYTHONPATH variable with .env file with relative paths #5061
Comments
One observation that might help with debugging this issue: Playing with the Content of
Output of
|
Do I have your file layout correct? I also tried this with the subdir and that is also working. vscode_test_project (.env file in here) |
@IanMatthewHuff Thanks for looking into this. Yes your directory structure is correct. See my attached screenshots. You seem to be using linux for reproducing this. I think this might be a windows-specific problem. My second post indicates that there are problems with variable substitution on windows. I.e. why else would adding a Please let me know if there is anything I can do to help you debug this. Alternative 1: simple Alternative 1: |
Another thought: could part of the issue be that my project path contains a space? |
Just realized I can test this myself of course. I move the |
@secure-mail-documentation-project Sorry about this being hard to work through, without having the issue on my box it's a bit hard to debug. This isn't a full fix but as a possible workaround, we have a setting to specifically run python commands at the start of any notebook or interactive window session. If you have python code to manually add something into sys.path you could put it in here and that should run that code for any interactive sessions that you start. The setting is Jupyter: Run Startup Commands. Currently I'm looking at all the info on configuring .env files here: One thing to try. With just the PYTHONPATH specified instead of printing out sys.path could you instead import os and print os.environ? I'd like to see what the PYTHONPATH looks like there before it gets added to the sys.path. |
No problem. I have some self-interest that this get's fixed. I am happy to help debug it. Output of
The
|
@IanMatthewHuff Looking at the I did notice a curious effect however to do with changing the
If one however modifies
Output of
Output of
Further observations:
It would appear that the On a sour note: the question of what relative |
@greazer I just saw, that you added 'info-needed'. Could you please explain what you need to proceed? As far as I am aware, I have provided all info requested by @IanMatthewHuff. Did I misunderstand something? I am more than happy to help debugging this. |
In my case, the .env file doesn't load at all for a .env file as simple as,
then check with,
|
I've managed to identify the cause of the issue, when using non-conda issues we dont use the env variables at all. |
Issue Type: Bug
The jupyter extension sets the PYTHONPATH variable incorrectly when a
.env
file contains relative path definitions.To reproduce:
C:\Users\My User\Documents\vscode_test_project
.env
file in above direcory with the contentPYTHONPATH=./some-library
subdir\test.py
in above directory that is empty except for the line# %%
opened in editorimport sys; sys.path
Expected result:
Actual result:
Note the invalid value of the second line containing the path for
some-library
. This should always be relative to the location of the location of the.env
file.Also of concern to me seems to be the first line that seems to contain part of an error message with
.does-not-exist
.Extension version: 2021.2.603412351
VS Code version: Code 1.53.2 (622cb03f7e070a9670c94bae1a45d78d7181fbd4, 2021-02-11T11:48:04.245Z)
OS version: Windows_NT x64 10.0.18363
System Info
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
The text was updated successfully, but these errors were encountered: