You are here
Table of Contents
Python is an interactive, object-oriented, extensible programming language. There is a Python distribution on each WestGrid system, which was installed as part of the basic operating system environment. However, more recent versions are typically also available. To select one of these updated versions, one typically will have to use a variation on the module load python command, as indicated in the usage instructions on the Python Software Versions page. The use of modules to configure software is explained on a separate page. Please note that these modules are completely unrelated to the Python modules discussed below.
Much of the utility of Python comes from modules that have been installed to extend the base functionality. Some of these modules (NumPy, SciPy and matplotlib, for examples) are available on most WestGrid systems, whereas others have been installed in response to requests on specific systems. It would be expensive to maintain a complete and up-to-date list of modules available for each version of Python on all the WestGrid systems. Instead, in this section, we discuss commands one can use to determine which modules have been installed. The specific commands depend on which Python distribution is being used and the level of detail that is required. Some examples are given here.
With all Python distributions, the following commands will give a detailed list of modules that are available, but, does not show the version number:
Alternatively, one can use the pydoc command (at the Linux shell prompt, not at the Python prompt) to avoid a bit of typing:
Once the name of a particular installed module is known, the Python help command can also be used to show any associated documentation for that module, which often shows the version number. Be sure to include the module name in single quotes when using help. For example, at the Python prompt:
Alternatively, one can call up the documentation from the Linux shell prompt with the pydoc command:
Version numbers are also available for many modules (but, not all) using the __version__ attribute. You must import the module before issuing the associated version command. Note the module name is followed by a period, with two underscores before and two underscores after the word version.
With some Python distributions, the command
can be used to get the names of installed packages along with their version numbers. However, there are some limitations with using pip. Some installed modules may not show in the pip output and the pip command itself may not be available with some Python installations. With some older versions of pip, the list option is not available, but,
can be used instead to give similar output.
Also, you have to be careful that the pip command you are using is associated with the Python installation in which you are interested. You can check with
to see which installation is associated with the current pip command.
With Python 3.x distributions there is a pip3 command that can be used in a similar manner to pip.
For the Anaconda Python installations on Grex, the conda command can be used at the Linux shell prompt to get a list of installed modules, along with version numbers:
For More Information
2014-03-18 - Added section on commands to determine which modules have been installed.
2014-03-21 - Added pip3 reference.