Installing Software

How do I install software?

You can install software under your home directory. Most software support installation under non-system locations. If you are building from source, you can change the install location to some directory in your home directory. For instance, in the traditional method of building softwrae from source code, generally called the configure-make-install method, you could set the install location in the configure step using the --prefix= option.

Here is an example of installing a software named foo in a directory named bar (in your home directory) from the source file foo.tar.gz

tar xvzf foo.tar.gz
cd foo
./configure --prefix=~/bar
make
make install

After a successful build, you would find a typical directory structure under the install directory:

bar
├── bin
├── lib
└── share

Now to use this software, you would need to add the install paths for binaries and libraries (at the least) to your environment variables:

export PATH="~/bar/bin:$PATH"
export LD_LIBRARY_PATH="~/bar/lib:$LD_LIBRARY_PATH"

How do I install Python libraries?

You may install Python libraries under your home directory. The easiest way to do this is using pip. If the library is not available via PyPI, you might need to build it from source, using the instructions above.

When installing via pip, the install files go under the .local directory under your home directory. Let’s say you want to install a Python library named foo.

pip3 install foo --user

Now, you should be able to use the library you just instaled.

>>> import foo
>>>
Python Virtual Environments

You can create Python virtual environments to install different Python libraries. This is very helpful when you’re working on multiple research papers or courses requiring different versions of libraries and want to keep everything organized separately.

Since we have various sources and versions of Python available, you should first load the right environment module depending on the Python version you want to use. After that, creating a virtual environment on CS machines is similar to doing it on any other Linux machine.

To create a virtual environment using Anaconda, you would do:

module load python/anaconda
conda create -n my-env python=3.x anaconda

And to create one using “venv” you would:

module load python/bundle-3.x
python3.x -m venv my-env

Please note that if you install Python libraries within your virtual environment, additional configuration of your environment paths may be required. This depends on the method used to create your virtual environment and its location.

If you have loaded one of the Python bundles via environment modules, you do not need to set the paths above. The modules take care of that automatically.

The Anaconda environment module does not automatically handle user-installed Python paths, so you will need to set the paths appropriately.