The most common cause of Jupyter stopping working is conflicts with user-installed python packages.
The ASU Supercomputers offers a python-environment manager, mamba, which can help alleviate these issues by keeping python packages properly contained.
This page describes the inner-workings of installing packages via various python methods and the impacts it may have.
Differences between installation methods
Environment Activated? | Installer | Command | Default Install Location | Note |
---|---|---|---|---|
No mamba/no env | pip | pip install package_name | /usr/local/lib/pythonX.X/site-packages | This location is not user-writable, so python may default to installing to your $HOME. Avoid this route. |
pip (with --user) | pip (with --user) | pip install --user package_name | ~/.local/lib/pythonX.X/site-packages | This location is user-writable, but installs packages in a location Jupyter Notebook/Lab uses on the Web Portal. Avoid this route. |
source activate YYYY | mamba | mamba install package_name | ~/.conda/envs/<envname>/lib/pythonX.X/site-packages | This location is user-writable and will be installed properly via mambas safeguards. PREFERRED route. |
source activate YYYY | pip | pip install package_name | ~/.conda/envs/<envname>/lib/pythonX.X/site-packages | This location is user-writable and will be installed properly via mambas safeguards. This is an ACCEPTABLE route for packages that cannot be installed via mamba. |
source activate YYYY | pip (with --user) | pip install --user package_name | ~/.local/lib/pythonX.X/site-packages | This location is user-writable, but installs packages in a location Jupyter Notebook/Lab uses on the Web Portal. Avoid this route. |
MAIN TAKEAWAYS:
Prefer
mamba install
everywhere, where possible.Never use
pip --user install
Only use
pip install
after source activating your environment.
Technical details
Background about Python Libraries Locations
When running python
, python2
, or python3
, additional libraries are identified and python attempts to load these into the current session from /home/<asurite>/.local/lib/python<version>/site-libraries
.
This is the default behavior of python, and in many cases for workstations, a dependable and time-saving functionality.
However, this default behavior is potentially disruptive when using Jupyter, which fully contains all the necessary packages in a curated, version-locked manner.
Background about Mamba-contained libraries
When using mamba create
and mamba install
, libraries are placed in to /home/<asurite>/.conda/envs/<envname>
. This means you can have multiple environments that are completely independent of eachother which maybe both include the same packages, but do not interfere with eachother and can have different (and potentially conflicting) versions.
The selection of the environment is done with source activate
and this ensures all mamba install
and pip install
remain safely contained within.