Python on the CS Linux Clients

All of the CS Department's Linux clients have both Python 3 and Python 2.7 installed. The default version is Python 3. This page has some information about how Python works in our environment.

You may also want to read about Python on the CS Webservers.

Note: Python 2 is Deprecated

Although Python 2.7 is installed on our systems, it should only be used when needed for compatibility with older programs. Official support for Python 2 ended in January 2020. New programs should use Python 3, and old Python 2 programs may not work properly. If a program does not work with Python 2, the solution is to port it to Python 3.

Python 3 has been the default version of Python on our systems since early 2020. We plan to completely remove Python 2 from our Linux clients sometime after the Fall 2020 semester.

Installing Python Packages

We try to have a good selection of the most-commonly-useful Python packages preinstalled on the Linux clients. It sometimes happens that people need one or more packages that aren't currently installed. Here's how you can get the packages you need.

pip

pip is installed on our systems, so if you need a package (and if it's in the Python Package Index), you can install it for your own personal use with:

pip install --user package

If you need a Python 2 package, use pip2 instead of pip.

Note that, for ugrad accounts, the package will count against your disk quota.

Removing a package you installed is as simple as:

pip uninstall package

pip will figure out on its own that it was locally-installed.

virtualenv

For complete control over what Python packages are available, you can use virtualenv. It uses a directory to hold a complete set of packages that are entirely independent from whatever is installed in the system (or in your home directory via pip install --user).

To use a virtual environment, pick a directory where it will keep its data and use the virtualenv program to initialize the directory. For example, if you want to make a "project-1" environment and keep all of your environments in a "~/python" directory, you could do this:

virtualenv ~/python/project-1

To start using the virtual environment, you must use one of the "activate" scripts in the environment's "bin" directory. If your login shell is bash or zsh, use activate . If you're using csh or tcsh, use activate.csh . (See How to Tell What Shell You're Using if you're not sure what your shell is.) Load the appropriate script with the source command:

source ~/python/project-1/bin/activate

Your shell prompt will change to show the environment you're using. No packages will be available to start with, but you can install them with "pip install package" (without the "--user" parameter).

To leave the virtual environment, simply use the deactivate command:

deactivate

If you have a ugrad account, you will need to make sure you don't exceed your disk quota.

Request Systemwide Installation

If the package is likely to be useful for a number of different people or if there's some reason you can't install it into your home directory, you can ask us to install it systemwide via our software installation request procedure.

Please note that, while we try to accommodate most requests, we cannot guarantee installation of any particular package.