Matplotlib for Python scripting in ArcGIS 10 does not work

6483
21
06-29-2011 12:50 PM
wernerrolf
New Contributor
I use ArcGIS 10 and would like to run Matplotlib to create charts within a python script. Therefore I have installed
- numpy-1.6.1rc1-win32-superpack-python2.6.exe
- matplotlib-1.0.1.win32-py2.6.exe

as noted here: http://matplotlib.sourceforge.net/users/installing.html

If I test a script to check the installation like:

import numpy
arcpy.AddMessage("NUMPY Version " + numpy.__version__)

import matplotlib
arcpy.AddMessage("MATPLOTLIB Version " + matplotlib.__version__)

I get the following error:
Running script Script...
NUMPY Version 1.6.1rc1
<type 'exceptions.AttributeError'>: 'module' object has no attribute '__version__'
Failed to execute (Script).

Also the command
- import pylab as pl

leads to the error
<type 'exceptions.ImportError'>: No module named pylab
Failed to execute (Script).


So even matplotlib is installed properly in the directory "site-packages" (see screenshot of directory structure attached) it does not work in ArcGIS.


By the way if I let it run in iPython (same installation) it works perfect.

What still needs to be done to get matplotlib work in ArcGIS 10?

Thanks
Werner
Tags (2)
0 Kudos
21 Replies
SamuelMcDeid
New Contributor II
Thanks Shaun for the reply. Sadly adding the Python installation to the system PATH variable didn't work. It came up with the same problem. I also tried using PIP to install spyder, but then it was having issues with PyQt4, which it claimed I didn't have installed (even though I had installed it first). I'm not sure what is my problem here. I love working in spyder, it made programming much less confusing and it went quicker when I could use it.
0 Kudos
ShaunWalbridge
Esri Regular Contributor
I did get Spyder to work, and my guess is that one of the many pathing "gotchas" is to blame. Could you try searching your disk for any other instances of python.exe, and see if others show up beside the version you've installed for ArcGIS? It's not uncommon for a few instances to be installed side-by-side, and in that case it takes some delicate work to insure that Spyder (and its dependencies like PyQt4) all end up being installed into the same Python instance. I'm happy to keep plugging away with you to get this working.
0 Kudos