Ubuntu HPC Installing different versions of python
Home > Ubuntu > Ubuntu HPC setup with slurm and linux containers > Ubuntu HPC Installing different versions of python
Install Python from Source (Python 3.8.13)
Follow these steps to install Python 3.8.13 from source. This approach allows for installation in a custom directory without interfering with system Python.
1. Prepare the Build Environment
Navigate to a temporary directory used for compiling source files:
cd /export/apps/temp
Download the Python 3.8.13 source tarball:
wget https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgz
Extract the archive:
tar -xf Python-3.8.13.tgz cd Python-3.8.13
2. Create the Installation Directory
Choose a location where Python will be installed:
mkdir -p /export/apps/python/python-3.8.13
3. Configure the Build
Run the configure script to test the system and enable optimizations. Use --prefix to specify the custom install path:
./configure --enable-optimizations --prefix=/export/apps/python/python-3.8.13
4. Build and Install Python
Use make with parallel jobs (-j) to speed up the build process. Adjust 10 according to the number of available CPU cores:
make -j 10 make install
Once installed, Python 3.8.13 will be available at:
/export/apps/python/python-3.8.13/bin/python3.8
Notes
Installing Python from source using this method provides flexibility to build and deploy specific Python versions without interfering with the system-wide Python installation. This approach is especially useful in HPC environments where different users or applications may require different Python versions.
Using the same procedure outlined above, you can install multiple versions of Python (e.g., 3.7.x, 3.9.x, 3.10.x, etc.) in isolated directories. Once installed, these versions can be exposed to users through environment modules. This ensures clean separation of software environments and avoids version conflicts across the cluster.
By configuring Python as a module, users can load the required version of Python for their job or workflow using the module load command. This improves reproducibility, consistency, and user autonomy in a shared HPC environment.
For detailed instructions on configuring environment modules, please refer to the following page: Ubuntu HPC Install and Configure Modules
Home > Ubuntu > Ubuntu HPC setup with slurm and linux containers > Ubuntu HPC Installing different versions of python