5

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?

7
  • Hey there, looks like your post is missing the link to the stackoverflow to which you are referring!
    – GISHuman
    Commented Aug 13, 2014 at 15:17
  • right. sorry. fixed. thx.
    – Roland
    Commented Aug 13, 2014 at 15:33
  • 1
    I'm using multiple versions of Python to get around this. I've installed the Anacondas package which is similar to Enthought, but is free. I use a .pth file in both the Anacondas and Arc directories to link libraries. I will try to find a link to a description of the method. Commented Aug 13, 2014 at 15:38
  • 1
    Here is a link to another stackexchange question that should help you out. I used Rich's method and applied it to my installation of Anacondas: gis.stackexchange.com/questions/59012/… Commented Aug 13, 2014 at 15:58
  • 2
    Here is another link: rsignell.tiddlyspot.com/… Commented Aug 13, 2014 at 16:01

1 Answer 1

14

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

4
  • Let us know if you have success building a newer version.
    – nmpeterson
    Commented Aug 14, 2014 at 16:13
  • 1
    Did this for Arc 10.3 (python=2.7.8 numpy=1.7.1) and it built using pandas 0.13.0. Worked great, finally have pandas working in arcpy, thank you!!!
    – brokev03
    Commented Mar 8, 2016 at 15:54
  • For the one line in conda.pth, do you just need the file location or should it be prefaced by something like %PATH%? -- not a windows user
    – J Kelly
    Commented Sep 29, 2016 at 13:27
  • What if you create the environment, and then realize that a package is missing? Such as netcdf4... can I install it inside the environment I have just created?
    – FaCoffee
    Commented Jan 26, 2017 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.