Installing Python packages locally
The process of setting up Python for your personal use and needs consists of first choosing a Python distribution and setting up the environment using modules, and second adding any custom packages to your environment locally. These two steps are discussed below.
This guide is only suitable for light-weight use in situations that require only a few packages with minimal dependencies or other needs. For more complex conditions and for situations that require reproducibility in package contents, or to allow switching between different sets of packages for different workflows, the more comprehensive approach described in our guide on Installing a Local Copy of Python Using Miniforge is preferred.
Choosing a Python distribution and setting up the environment
As with all user-selectable system-supplied software at the HPCC, modules are used to select the Python distribution to be used and set up a user's environment. Typically users initialize their environment when they log in by setting environment information for every application they will reference during the session. The HPCC uses the Environment Modules package as a tool to simplify shell initialization and allow users the ability to easily modify their environment during the session with module files.
For more information about how to load and maintain your software environment using modules, please refer to the user guide "Software Environment Setup".
In order to select a distribution and set the environment variables for Python you will first need to check which versions of Python are available using the HPCC Software List page. This command will return a description of the software and which versions are currently installable through the modules systems.
The default version of Python on all partitions can be loaded by:
module load python
Installing packages locally to supplement or replace a system distribution
By default, Python packages require the installation be performed by the 'root' user. However, most Python package installers and managers will also allow the user to install the package into their HOME folder to supplement the features of these distributions.
You can alternately choose to use Miniforge through the Conda package manager, which will enable you to use a newer distribution of Python than the system defaults. Using the Conda package manager allows you total control over the Python setup for your code without any dependencies on system Python versions.
Below you will find instructions for installing python packages locally using the following methods:
Installing Packages Locally with pip
Pip is the PyPA (Python Packaging Authority) recommended tool for installing Python
packages. As such, many Python packages can be installed using pip. The problem
with pip is that if you attempt to install a package without root access, the tool
will simply fail and give you no hint that you can install the package without root.
In order to bypass the need for root access you can instruct pip to instead install
to your HOME folder by adding the --user option as shown below:
Python 2:
pip install --user <package>
Python 3:
pip3 install --user <package>
Installing Packages Locally with easy_install
Easy_install is another commonly used tool for installing Python packages and is a
supported method for the installation of many packages. Similar to pip, this tool
will also fail if you attempt to install a package without root access. Unlike pip,
when easy_install fails it does hint that it is possible to install without root but
it does not give you the command to make it work. In order to bypass the need for
root access you can instruct easy_install to instead install to your HOME folder by
adding the --user option as shown below:
easy_install --user <package>
Installing Packages Locally from Source
Many Python packages also allow the user to install them directly from their source
code. Often these packages provide a "setup.py" file for the purpose of installing
these packages. Much like pip and easy_install, adding a --user flag is often sufficient for setup.py to install the package directly into your HOME
folder. This can be done using the command shown below:
python setup.py install --user
Installing Packages using the Conda Package Manager
Some users find themselves needing to install a different version of a package that the HPCC has installed, which will then often override the version you attempt to install into your local HOME directory. Users also sometimes encounter Python packages with an immense number of dependencies that make installing them difficult. If you find yourself needing to install a complex Python package, a package version different from the one we provided or if you simply need a specific version of Python then we strongly suggest you install a copy of the Conda package manager into your HOME folder. The Conda package manager will allow you to fully control your Python environment and often makes the installation of complex Python workloads as simple as a few Conda commands. The HPCC provides documentation for the installation and usage of Conda, which can be found here: Installing a local copy of Python using Miniforge
Please contact HPCC support at hpccsupport@ttu.edu if you have any questions.
High Performance Computing Center
-
Phone
806.742.4350 -
Email
hpccsupport@ttu.edu