ground- water, geo- statistics, environmental- engineering, earth- science

Python: How to start and how to make python(x,y) work with ArcGIS 10

without comments

In the end, it comes down to finding a little project and you have to figure stuff for yourself on the way. My hope is that this write-up saves you some time with technicalities.

My python setups are different between my mac and my windows machine — on windows I am largely limited by the python version that ESRI imposes with Arc10. On my mac, there is no such thing. The link between ArcGIS and me is still existent from my M.Sc. work. A side project back then was to build a calibration tool that is not only based on point measurements. Instead, the goal was to get the general hydraulic head surface in the two main aquifers reasonably right. Back then I delved into VBA, and it worked. Back then we were using Arc 8.0, and the inclusion of python in Arc was just starting (and numpy either didn’t exist or I didn’t know about it). I am still not very happy with the implementation of python in ArcGIS, but it is one of the reason, why I keep 2.x versions around. A current ESRI view is expressed here and in these pdf slides


There are several python versions out there. The big distinction is between versions 2.x and 3.x. Obviously, 3.x is newer, but a lot of packages (“modules”) are compatible to 3.x yet. Hence, I would suggest, for now, to stick with 2.x — currently, I use 2.7.3. on the mac and 2.6.x on windows

Where do I get the installer from?

Python is open source, and basically, you can get an installer right from the python homepage. Probably, this is a smart way to do. Even smarter it would probably be to download the source and compile it directly on your machine. But, we are no computer scientists. Plus you will need a few more packages (“modules”), despite the fact that python comes with “batteries included“, i.e. a lot of powerful possibilities within the standard library (the “pure” version that you can install from

To facilitate, there are a few people/organisations who provide packaged “python distributions”, which are updated in certain intervals. However, if you always want the bleeding edge version of a module, you can’t go that path.

I use the “Enthought Python Distribution” (EPD) on the mac, which is free for educational use. On windows, a good way to go is probably pythonxy. Other options on the mac include the Scipy Superpack or a combination of homebrew and pypi installs.

Installation with ESRI Arc10

I found that this hack works for me. It is based on information that I collected on various webpages (sorry for lack of reference here). I am sure there are other/better solutions. Please let me know! 😉

  • install ArcGIS 10 WITHOUT python (unfortunately, this could mean to de-install it first completely)
  • install python(xy) in C:\python26 (download)
  • create a file that is called Desktop10.pth, and put the following three lines (ASCII) into that file:
    C:\Program Files (x86)\ArcGIS\Desktop10.0\bin
    C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy
    C:\Program Files (x86)\ArcGIS\Desktop10.0\ArcToolbox\Script

  • copy that file into the directory C:\python26

Where to write code (IDEs)

For windows, this is a no-brainer, because it is so awesome: pyscripter. On other OSes, I use eclipse, with the pydev plugin.

Packages (“Modules”)

  • Numpy: numerical library (“numerical python”): read from files directly into arrays, matrix algebra, basic stats — this is so awesome and so much fun! This page will be your best friend!
  • Scipy: the sister of numpy — “scientific python”: all kinds of goodness: optimizers, fft, all kinds of statistics, image processing
  • matplotlib: make awesome plots straight out of python (similar to matlab); somewhat limited still to 2D, even if 3D is possible
  • pandas: if you ever have to deal with data that has time stamps – use pandas!
  • basemap: In the last little while I have dealt mostly with rasters, and it is quite easily possible to display them in matplotlib using the command “imshow”. For more advanced mapping related stuff, basemap might be an option (check out their gallery)

There are many, many more. And you can write your own packages (such as copyla)

Where to start

I think the best starting point is the python tutorial. After this I would go to the scipy/numpy/matplotlib “lecture notes“. Andy Terrel has put together a good resource page, but I think it is a bit advanced.


There are many books. Generally, I read through parts of I think all the o’reilly ones, and I can recommend them, even if I don’t own any. I do own the one by John Zelle, which I enjoy, but it covers general computer science concepts, using python, but it is not really ideal to learn python. Geoff has one of the Langtangen books, which are all very good. Generally, there is so much information available online, that I find books become more and more obsolete.

Written by Claus

October 24th, 2012 at 5:21 am

Posted in

Leave a Reply