Installing Python Packages

On this page:


Overview

In IDAS, Python packages can be installed in several ways:

 

This article outlines the steps to install Python packages using pip (Option 1 above). We also recommend using tools like Python Virtual Environments and Conda in IDAS to manage your projects.

Installing Python packages in Jupyter Notebook

1. First, log in to the IDAS research instance with Python. If you are a student in a class that uses Python in IDAS, follow the instructions here to access your class instance.

2. In JupyterLab, click the "Python 3" tile under "Notebook" to start a Jupyter notebook.

3. Write the following code in a new cell of the notebook, filling in the name of the package that you want to install. Run the cell with the keyboard shortcut Shift+Enter:

!pip3 install --upgrade package-name

 

Example

For example, suppose we want to install the package TheFuzz, which is available from PyPI: https://pypi.org/project/thefuzz/.

In the following screenshot, cell 1 shows the installation command and its output in a Jupyter notebook. Cells 2 and 3 test a simple example from https://pypi.org/project/thefuzz/ to ensure the package has been installed.

Click on the screenshot to view an enlarged version.

Installing Python packages in Terminal

1. First, log in to the IDAS research instance with Python. If you are a student in a class that uses Python in IDAS, follow the instructions here to access your class instance.

2. In JupyterLab, click the "Terminal" tile under "Other" to start a Terminal session.

 

3. In Terminal, type the following command, fill in the name of the package that you want to install, and press Enter:

python3 -m pip install --user package-name

 

Example

For example, suppose we want to install the package TheFuzz, which is available from PyPI: https://pypi.org/project/thefuzz/.

The following code block shows the installation command and its output in Terminal:

grudderham@idas-research-grudderham:~$ python3 -m pip install --user thefuzz Collecting thefuzz Obtaining dependency information for thefuzz from https://files.pythonhosted.org/packages/19/7d/ca50835332895beb87e663f9a610a7e0a7335b69e31177aee87acc3db9bd/thefuzz-0.20.0-py3-none-any.whl.metadata Downloading thefuzz-0.20.0-py3-none-any.whl.metadata (3.9 kB) Collecting rapidfuzz<4.0.0,>=3.0.0 (from thefuzz) Obtaining dependency information for rapidfuzz<4.0.0,>=3.0.0 from https://files.pythonhosted.org/packages/9e/ae/33dd7c9a6f06c25dfb7e556756fb4adbcea1ec2c8c7efc8aaecb106ac882/rapidfuzz-3.5.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata Downloading rapidfuzz-3.5.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (11 kB) Downloading thefuzz-0.20.0-py3-none-any.whl (15 kB) Downloading rapidfuzz-3.5.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 25.2 MB/s eta 0:00:00 Installing collected packages: rapidfuzz, thefuzz Successfully installed rapidfuzz-3.5.2 thefuzz-0.20.0 [notice] A new release of pip is available: 23.2.1 -> 23.3.1 [notice] To update, run: pip install --upgrade pip



Test the package with a simple example from https://pypi.org/project/thefuzz/ to ensure it has been installed:



After the package has been installed, it can also be used from a Jupyter notebook.

Open a new Launcher page in JupyterLab:



From the Launcher page, start a Jupyter notebook:



Run the code from a Jupyter notebook:

Click on the screenshot to view an enlarged version.

Notes about Python package installation

1. The following resources may be helpful:

 

2. In IDAS, Python packages that have been installed by a user are available in the user library:

where HawkID is your HawkID, and pythonx.x indicates the Python version, for example, Python 3.11.

 

3. After installing a Python package in Terminal, if you have trouble importing the package, you might need to add your user library to the PATH environment variable.

The following steps are done in Terminal:

First, crease a .bashrc if you haven't done so before:

Add your user library to PATH:

And then run the following in Terminal. Note that .bashrc needs to be sourced every time you start a new Terminal session.

Contact

If you have any questions or comments, please contact ITS - Research Services at research-computing@uiowa.edu.