Install Python

From PLplotWiki
Revision as of 15:13, 13 December 2010 by Airwin (Talk | contribs)

Jump to: navigation, search

Python2 is the high-level language of choice for many scientific programmers so the PLplot developers have made sure their Python2 bindings and their standard set of 33 Python examples to test and illustrate those bindings are supported in a first-class way. To make this powerful component of PLplot available on Windows, it is necessary to download a Windows version of Python and NumPy (the subset of SciPy that allows arithmetic operations on scientific arrays at C speeds from Python).

To obtain the latest version of Python2 for Windows, download the Python installer from http://www.python.org/ftp/python/2.7.1/python-2.7.1.msi. (These instructions assume you have a 32-bit Windows platform which, e.g., is the standard choice for the wine platform even on 64-bit machines. If you prefer the 64-bit choice for Python, then explore the above URL for MSI files with AMD64 in their name.) Run the MSI installer. I don't know how to do that on Microsoft Windows, but on wine the command is "wine msiexec /i python-2.7.1.msi". After the installer GUI comes up, I recommend making all default choices _except_ for the installation prefix where I suggest you choose something unique which allows you to easily remove and replace Python installations when you need to without interfering with other downloaded software packages. From here on I assume that prefix is called $PYTHON_PREFIX.

To obtain the latest version of NumPy. download the NumPy installer from http://prdownloads.sourceforge.net/numpy/NumPy/1.5.1/numpy-1.5.1-win32-superpack-python2.7.exe and run it. (For example, on wine you run that installer with the "wine numpy-1.5.1-win32-superpack-python2.7.exe" command, and I assume you do the same on the Microsoft Windows command-line by dropping "wine" from the command. When the NumPy installer GUI comes up, my experience is it automatically finds the Python2 installation above for whatever you have chosen for $PYTHON_PREFIX so that I was able to use the default choice in all cases.

After installation of Python2 and Numpy, the remaining steps are to inform CMake (the build system software used by PLplot) of the location of those installs. To do that prepend the following data to the indicated environment variables which are assumed to be set already. That assumption is correct in the PATH case, but if CMAKE_LIBRARY_PATH and/or CMAKE_INCLUDE_PATH have not been set up before then drop ":$CMAKE_LIBRARY_PATH" and/or $CMAKE_INCLUDE_PATH from the following commands and use the "export CMAKE_LIBRARY_PATH" and "export CMAKE_INCLUDE_PATH" commands as appropriate.

PATH=$PYTHON_PREFIX:$PATH

CMAKE_LIBRARY_PATH=$PYTHON_PREFIX/libs:$CMAKE_LIBRARY_PATH

CMAKE_INCLUDE_PATH=$PYTHON_PREFIX/Lib/site-packages/numpy/core/include/numpy:$CMAKE_INCLUDE_PATH

CMAKE_INCLUDE_PATH=$PYTHON_PREFIX/include:$CMAKE_INCLUDE_PATH