Jupyter notebook doesn't load env variables
See original GitHub issueDoes this issue occur when all extensions are disabled?: Can’t check because i only have a remote ssh access to the concerned computer.
- VS Code Version: Version: 1.62.1 Commit: f4af3cbf5a99787542e2a30fe1fd37cd644cc31f Date: 2021-11-05T10:56:50.217Z Electron: 13.5.2 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Linux x64 5.4.0-89-generic snap (Ubuntu 18.04.5 LTS)
I’m not sure how to reproduce this issue since it mysteriously stopped working overnight. Anyway, here what happens:
- I’m running vs-code remotely via SSH. I’m running python inside a venv. I have a variable inside my .bashrc file alike:
export SOME_VARIABLE=/some/path/
so that in a python file, os.getenv(‘SOME_VARIABLE’) works just fine.
-
However inside a jupyter notebook (with the good kernel), this variable is set to None. If it can help, the PYTHONPATH is: /path/to/my/home/.vscode-server/extensions/ms-toolsai.jupyter-2021.10.1101450599/pythonFiles:/path/to/my/home/.vscode-server/extensions/ms-toolsai.jupyter-2021.10.1101450599/pythonFiles/lib/python
-
I tried setting:
"terminal.integrated.inheritEnv": true,
"terminal.integrated.defaultProfile.linux": "bash",
in the json settings file but it didn’t change anything.
I guess this is a jupyter bug since it works in a python file.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:11 (5 by maintainers)
Top GitHub Comments
Sorry but that’s not supported. Your .bashrc won’t be run before we start a kernel.
You could workaround this by setting this value to set some environment variables:
Or we could change this issue to an enhancement and add an option to run a kernel from a shell script instead of launching it directly.
Sorry I’m not following what you’re doing here.
VS code itself has to be started from a terminal with the environment variables set. Like so: