Install Python packages

The role ufrmath.computer_labs.install_pip is used to install Python additional packages from PyPI which are not available in the Ubuntu repository.

The strategy is to install these additional packages in /usr/local/ in order to to conflict with the Python packages installed by the distribution.

For example, to install JupyterLab in /usr/local/ with Pip:

sudo pip3 --prefix='/usr/local' --upgrade --ignore-installed jupyterlab

and to add some shortcut to JupyterLab:

[Desktop Entry]
Name=Jupyter Lab
Comment=Run Jupyter Lab
Exec=jupyter-lab
Terminal=true
Type=Application
Icon=notebook
StartupNotify=true
MimeType=application/x-ipynb+json;
Categories=Development;Education

As always with packages installed with Pip it is not so easy to remove or upgrade dependencies. To this end it might be desirable to purge all packages installed in /usr/local/ and start from clean. The list of Python packages installed in /usr/local/ can be listed with the following script:

#!/bin/env python3
import pkg_resources
local_pkg = [p.project_name for p in pkg_resources.working_set if "/usr/local" in p.location and p.project_name != 'pip']
print(local_pkg)

and then removed using pip uninstall.

Previous
Next