Esri Python – Installing Pandas with Esri’s Python

arcgis-10.2arcpynumpypandaspython

Trying to get pandas to import, but I'm getting what looks like an error caused by a failed dependency of the version of my Esri-provided numpy's compile, based on this stackoverflow posting. Here's what I get.

>>> import pandas
numpy.dtype has the wrong size, try recompiling
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:\Python27\ArcGIS10.2\lib\site-packages\pandas\__init__.py", line 6, in <module>
    from . import hashtable, tslib, lib
  File "numpy.pxd", line 157, in init pandas.hashtable (pandas\hashtable.c:22315)
ValueError: numpy.dtype has the wrong size, try recompiling

I check my numpy version:

>>> import numpy
>>> numpy.version.full_version
'1.6.1'

Based on this, I believe that this is the right version of numpy for the version of pandas I'm using (tried 13.1, 14.0, and 14.1).

I'm running the standard ESRI-shipped python for ArcGIS 10.2 (Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32).

>>> import arcpy
>>> arcpy.__file__
'C:\\Program Files (x86)\\ArcGIS\\Desktop10.2\\arcpy\\arcpy\\__init__.py'

Has anyone succeeded in getting pandas going this way or have ideas on what's wrong with my environment?

Should I update my numpy, which is supposed to be backwards compatible (according to user333700's text at the bottom of the stackoverflow posting), or is that likely to break my ArcGIS functionality?

Best Answer

I was able to get pandas working in ArcMap 10.1 using pandas packages already built for Anaconda.

One of the nice things about Anaconda (besides being free) is that it's easy to create environments with specific versions of python and numpy.

Try this:

Open a 32-bit Anaconda command prompt and type:

conda create -n esri101 python=2.7 numpy=1.6 pandas
activate esri101

Then create a file called conda.pth in your ArcGIS10.1 site-packages folder. On my machine this is C:\Python27\ArcGIS10.1\Lib\site-packages\conda.pth

In this file add one line that points to your Anaconda site-packages for the esri101 environment you created. On my machine this is:

C:\programs\Anaconda\envs\esri101\Lib\site-packages

Then fire up ArcMap and try import pandas.

The only unfortunate thing is that it looks like the latest pandas release anyone built for windows with python=2.7 and numpy=1.6 is pandas=0.10.1. I might try building a later version using this stackoverflow answer

Related Question