A quick post to make one of the features from the latest releases
jupyter_core more visible, which might be useful to users juggling between multiple virtual environments on a day to day basis.
jupyter --paths command tells where Jupyter looks for config and data files. It usually outputs something like the following:
$ jupyter --paths config: /home/user/.jupyter /home/user/miniforge3/envs/myenvironment/etc/jupyter /usr/local/etc/jupyter /etc/jupyter data: /home/user/.local/share/jupyter /home/user/miniforge3/envs/myenvironment/share/jupyter /usr/local/share/jupyter /usr/share/jupyter runtime: /home/user/.local/share/jupyter/runtime
Here we see that the first entry on the list for the config files is
/home/user/.jupyter. Which means that all virtual environment will be sharing that same folder to store config files, for example JupyterLab settings and workspaces.
With recent releases of
jupyter_core, it is now possible to set the
JUPYTER_PREFER_ENV_PATH environment variable to change this order so the path to the virtual environment shows up first.
First make sure to have
jupyter_core>=4.7. For example to upgrade with
pip install -U jupyter_core
JUPYTER_PREFER_ENV_PATH environment variable can for example be set in the
~/.zshrc files, so it is set automatically when a new terminal is started:
Then in a new terminal, running the
jupyter --paths command will output:
$ jupyter --paths config: /home/user/miniforge3/envs/myenvironment/etc/jupyter /home/user/.jupyter /usr/local/etc/jupyter /etc/jupyter data: /home/user/miniforge3/envs/myenvironment/share/jupyter /home/user/.local/share/jupyter /usr/local/share/jupyter /usr/share/jupyter runtime: /home/user/.local/share/jupyter/runtime
This can be quite handy to keep environments well isolated.
More info in the documentation: Paths for Jupyter files — jupyter_core 4.8.0.dev0 documentation
Hope it helps!