Python on the CS Linux Clients

Revision as of 15:39, 9 November 2016 by Phil.cs.jhu.edu (talk | contribs) (Created page with "All of the CS Department's Linux clients have both Python 2.7 and Python 3 installed. This page has some information about how Python works in our...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

Installing Python Packages

We try to have a good selection of the most-commonly-useful Python packages preinstalled on the Linux clients and available for both Python 2 and 3. 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

For Python3, use pip3 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 you haven't changed your shell on our systems, use activate.csh . If you're using bash, use activate . Load the appropriate script with the source command:

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

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.