pysal

Table Of Contents

Previous topic

Introduction

Next topic

Getting Started with PySAL

This Page

Installing PySAL

Prerequisites

Before installing PySAL, make sure the following libraries are properly installed on your machine:

Optional, bundled installation:

With the Enthought Python Distribution (EPD), you will install all of PySAL’s required dependencies, as well as iPython and a lot more, rather than installing dependencies one by one. The package is free for academics, and downloadable here.

Required to compile the documentation (optional):

Optional, recommended additions:

Getting PySAL

You can install PySAL in a number of ways. We provide system-specific package installers for Windows and Mac OS X that have an intuitive look-and-feel that most users are familiar with. We also build source distributions that self-install by invoking a single command line argument. Finally, advanced users and developers can use the popular version control tool svn to check out and use our latest code. Instructions for each of these methods follows.

Downloads

Click-to-download PySAL distributions are available at Google Code. Choose the right one for your system, or grab a source tarball or zipfile.

Instructions for Windows

Grab the Windows installer (ends with .exe) and download to your computer. Double-click to launch the installer and follow the simple wizard. You will have to select the version of Python you want the package to install with, if you have more than one version of Python on your system. You may repeat this procedure for as many versions of Python as you have on your machine.

If you’d rather install source code, grab the zipfile (ends with .zip) and download to your computer. Decompress the file to a convenient location on your hard drive. Open a command shell and navigate to the decompressed PySAL folder. Type:

python setup.py install

Instructions for Mac OS X

Grab the OS X installer (ends with .mpkg) and download to your computer. Double-click to launch the installer and follow the simple wizard. This installer places PySAL into the active Python version on your system (the version that comes up when you type python into a terminal).

If you’d rather install source code, grab the tarball (ends with .tar.gz) and download to your computer. Decompress the file to a convenient location on your hard drive. Open a terminal and navigate to the decompressed PySAL folder. Type:

python setup.py install

Instructions for GNU/Linux

Grab either of the source distributions and decompress to your selected destination. Open a command shell and navigate to the decompressed PySAL folder. Type:

python setup.py install

Development version from Subversion (SVN)

Users and developers can grab the source code from our subversion repository using the following instructions, depending on the operating system:

GNU/Linux and Mac OS X

Use the command:

svn checkout http://pysal.googlecode.com/svn/trunk/ pysal

This will create a folder called ‘pysal’ containing all the source code. This will allow you to easily update any change that is made to the code by the developer team by running:

svn update

Since PySAL is in active and intense development, a lot of these changes are often introduced. For this reason it is preferable to ‘tell’ Python to look for PySAL in that folder rather than properly install it as a package. You can do this by adding the PySAL folder to the Python path.

To do that, open the bash profile (if it doesn’t already exist, just create a new text file in the home directory and name it .bash_profile) by typing in the terminal:

open ~/.bash_profile

Note: replace the command open by that of a text editor if you are in Linux (gedit for instance, if you are in Ubuntu). Now add the following line at the end of the text file:

export PYTHONPATH=${PYTHONPATH}:"/path_to_desired/folder/pysal/"

Save and quit the file. Source the bash profile again:

source ~/.bash_profile

You are all set!!! Now you can open up a fresh python session and start enjoying PySAL, you should be able to do (within a python session):

>>> import pysal
>>> pysal.open.check()
PySAL File I/O understands the following file extensions:
Ext: '.shp', Modes: ['r', 'wb', 'w', 'rb']
Ext: '.shx', Modes: ['r', 'wb', 'w', 'rb']
Ext: '.geoda_txt', Modes: ['r']
Ext: '.dbf', Modes: ['r', 'w']
Ext: '.gwt', Modes: ['r']
Ext: '.gal', Modes: ['r', 'w']
Ext: '.csv', Modes: ['r']
Ext: '.wkt', Modes: ['r']
>>>

Windows

To be able to use PySAL, you will need a SVN client that allows you to access, download and update the code from our repository. We recommend to use TortoiseSVN, which is free and very easy to install. The following instructions assume you are using it.

First, create a folder where you want to store PySAL’s code. For the sake of this example, we will name it PySALsvn and put it in the root folder, so the path is:

C:\PySALsvn

Right-click on the folder with the mouse and then click on ‘SVN checkout’. A dialog will appear. The ‘Checkout Directory’ refers to the path to your folder (C:\PySALsvn in this case). Copy and paste into the ‘URL of repository’ textbox, the following link:

http://pysal.googlecode.com/svn/trunk/

Once you click ‘OK’, a folder called ‘pysal-read-only’ will be created under C:\PySALsvn and all the code will be downloaded to your computer.

Now you have to tell Python to ‘look for’ PySAL in that folder whenever you import it in a Python session. There are several ways to do this, here we will use a very simple one that only implies creating a simple text file. Open a text editor and create a file called sitecustomize.py located in the Site Packages folder of you Python distribution, so the path looks more or less like this one:

C:\PythonXX\Lib\site-packages\sitecustomize.py

where XX corresponds to the version of the Python distribution you are using (25 for 2.5, for example).

Add to the file the following two lines of text:

import sys
sys.path.append("C:/PySALsvn/pysal-read-only")

Save and close the file. You are all set!!! Now you should be able to do the following in a Python interactive session (on IDLE, for instance):

>>> import pysal
>>> pysal.open.check()
PySAL File I/O understands the following file extensions:
Ext: '.shp', Modes: ['r', 'wb', 'w', 'rb']
Ext: '.shx', Modes: ['r', 'wb', 'w', 'rb']
Ext: '.geoda_txt', Modes: ['r']
Ext: '.dbf', Modes: ['r', 'w']
Ext: '.gwt', Modes: ['r']
Ext: '.gal', Modes: ['r', 'w']
Ext: '.csv', Modes: ['r']
Ext: '.wkt', Modes: ['r']
>>>

Known Issues

weights.DistanceBand failing

This occurs due to a bug in scipy.sparse prior to version 0.8. If you are running such a version see Issue 73 for a fix.

Troubleshooting

If you experience problems when building, installing, or testing PySAL, ask for help on the OpenSpace list or browse the archives of the pysal-dev google group.

Please include the output of the following commands in your message:

  1. Platform information:

    python -c 'import os,sys;print os.name, sys.platform'
    uname -a
  2. Python version:

    python -c 'import sys; print sys.version'
  3. SciPy version:

    python -c 'import scipy; print scipy.__version__'
  1. NumPy version:

    python -c 'import numpy; print numpy.__version__'
  2. Feel free to add any other relevant information. For example, the full output (both stdout and stderr) of the PySAL installation command can be very helpful. Since this output can be rather large, ask before sending it into the mailing list (or better yet, to one of the developers, if asked).