The World is Your Python
A guide to installing Python packages for scientific computing
Python is a great programming language,
and its power and versatility are enhanced by a large and growing
number of external packages and libraries which have been developed
and/or retrofitted to play well with Python, building on Python's own
tradition of coming with batteries included in the form of a
substantial standard library. Python packages are typically in the
form of pure Python source code, compiled binary libraries (e.g.,
shared object files or dll's), or a mix of both. While Python
packages have been developed to help with a number of different types
of problems in different disciplines, this document is
primarily focused on the
use of Python in computational science and engineering.
Unlike some scientific
computing environments (typically commercial products) which come
shrink-wrapped with everything their developers think you
should need, Python operates in a somewhat looser environment,
requiring more effort on the part of users to assemble a set of
desired packages.
This document describes packages are those needed for our course
on computational methods for nonlinear systems.
Simple Instructions
The simplest way to get started is to download the
Enthought Python Distribution
. They have packages for Window, Mac, Redhat Linux, and Solaris. It is free for academic use, and is easy to install.
Overview of the organization of Python
A few words about how a Python system is typically organized are in
order. An installed Python system consists of two main parts: the
Python interpreter (an executable binary file typically named python,
or python.exe on Windows systems), and the Python library (a mix of
Python source files (.py files), shared object files (.so) or dynamic
link libraries (.dll), and various byte-code compiled forms of Python
source files (.pyc, .pyo, .pyw)). The Python interpreter needs to
know where to find its associated libraries (which are found by
searching the interpreter's path, defined in the sys.path variable),
and an appropriately installed interpreter will have the corresponding
libraries in its default path. Typically the interpreter and the
library live under a common directory prefix, such as /usr/local on
Linux/Unix systems; in such a case, the interpreter would be found as
/usr/local/bin/python and the library will be stored under
/usr/local/lib/pythonX.Y, where X and Y refer to the major and minor
version numbers of the interpreter. Under the
lib/pythonX.Y directory is placed by default a directory called
site-packages, which is initially empty but which is meant to serve as
a repository for additional, third-party packages that are installed.
The site-packages directory is in the interpreter's default sys.path,
so anything correctly installed under site-packages will be available
for import within the Python interpreter. It should be noted that
multiple versions of Python can coexist, since each version of the
interpreter can find its associated library files. Python comes
pre-installed on many platforms,
but one can install a separate, customized version elsewhere
without disturbing the pre-installed version (which may be used for
many system configuration tasks, and probably shouldn't be
overwritten).
Depending on platform, different mechanisms exist for installing
additional Python libraries. Many packages that are installed from
source use the distutils
mechanism for building and installing the package
(perhaps using more recent "egg" technology to bundle
packages). Typically, one downloads and unpacks the package source code
(in the form of a tar.gz file) and then runs "python setup.py install"
within the package directory. (If multiple versions of python exist on
the system, one wants to make sure that the desired version is first in
the shell's path.) If one wishes to install the package
someplace other than where python resides, one can optionally specify
a location via the prefix flag, e.g., "python setup.py install --prefix=/usr/local" will install the package under /usr/local/lib/pythonX.Y/site-packages.
Versioning
The latest version of Python (as of July 2012) is Python 3.2. You do not want this version, as scipy does not work with it. The latest version of Scipy is 0.11, and it works with Python 2.7. This is the version in the Enthought package.
Packages needed for Cornell Physics 7682 / CIS 6229 (Fall 2012):
Computational Methods for Nonlinear Systems
We rely most heavily on scipy and matplotlib/pylab.
In addition, the Python Imaging Library (PIL)
is needed for some of the visualization tools provided
in the course, and VPython is useful for creating
animations in a few of the modules (Walker, Molecular Dynamics, and
the Repressilator). It is probably not essential to have the latest
version of all these packages, and ease of installation (e.g., via
Enthought on Windows, or fink on Mac OS X) may dictate
relying on distributions with slightly older versions.
VPython is not a part of Enthought, for some of the modules using VPython,
we offer a separate Enthought version which uses Traited VTK. You can
also install VPython on top of Enthought. Directions for doing this on OSX
are given here.
Packages
Installation instructions
Chris Myers
Last modified: Sat Feb 19 13:07:19 EST 2022