microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.29k stars 290 forks source link

VScode cannot read or use the 'PYTHONPATH' variable in the 'env' in kernel.json #13415

Closed lester1027 closed 11 months ago

lester1027 commented 1 year ago

Environment data

Expected behaviour

I added a kernel.json file under ~/.local/share/jupyter/kernels.

{ "argv": [ "/home/lester/anaconda3/envs/mne/bin/python", "-m", "ipykernel", "-f", "{connection_file}" ], "display_name": "Python 3 - MNE", "language": "python3", "env": { "PYTHONPATH": "/mnt/c/Users/leste/OneDrive/Frutta/MindAmp/git/eeg_device" } } The Jupyter kernel should be able the append the path(s) in the PYTHONPATH automatically.

Actual behaviour

Only the browser jupyter can do that. Vscode notebook fails in doing so. sys.path does not show the PYTHONPATH added

DonJayamanne commented 1 year ago

Thanks for filing this issue, I will have a look at this. For now, you can create a .env file in your workspace folder and add PYTHONPATH=... into that and the kernel will use that.

DonJayamanne commented 11 months ago

@lester1027 I have tested this and it works as expected. Please let me know if this problem still persists.

adrn commented 11 months ago

I'm seeing the same issue as raised by @lester1027, specifically when starting a kernel through a remote tunnel.