On this page:
Table of Contents |
---|
...
In IDAS, Python packages can be installed in several ways:
Use pip to install Python packages from the Python Package Index (PyPI)
Use pip and venv to create a virtual environment and install packages in that virtual environment (recommended)
Use conda to create a conda virtual environment and install packages in that conda virtual environment (recommended)
This article outlines the steps to install Python packages using pip. We also recommend using tools like conda and Python virtual environments 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 click the "Python 3" tile under "Notebook" to start a Jupyter notebook.
...
Code Block |
---|
!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:
...
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 click the "Terminal" tile under "Other" to start a Terminal session.
...
Code Block |
---|
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:
Code Block |
---|
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:
...
Run the code from a Jupyter notebook:
...
Notes about Python package installation
1. The following resources may be helpful:
This section from the official Python documentation has a list of key terms, basic usage, common tasks, and common issues: https://docs.python.org/3/installing/index.html
The pip documentation outlines common tasks. Please also see the User Guide and Reference, linked in the left sidebar: https://pip.pypa.io/en/stable/getting-started/
2. In IDAS, Python packages that have been installed by a user are available in the user library:
Code Block |
---|
/home/HawkID/.local/lib/pythonx.x/site-packages |
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:
...
Code Block |
---|
touch ~/.bashrc |
Add your user library to PATH:
Code Block |
---|
echo 'export PATH=$PATH:~/.local/bin' >> ~/.bashrc |
...
If you have any questions or comments, please contact ITS contact ITS - Research Services at research-computing@uiowa.edu.