Select to view content in your preferred language

Anaconda interfering with running spatial statistics in ArcMap 10.2

7826
8
02-11-2016 12:06 PM
EricEagle
Frequent Contributor

Hi Python group,

I'm running ArcGIS 10.2 with 64bit background geoprocessing. I've also got Anaconda 64bit configured as my preferred interpreter.  I can write in Spyder and call arcpy, no problems there.

My problem is that now, when I run spatial statistics scripts, it will error out.  I tried running optimized hot spot analysis today and it gave me this:

Trackback (most recent call last):

     File "c:\program files (x86)\arcgis\desktop10.2\ArcToolbox\Scripts

\OptimizedHotSpotAnalysis.py", line 30, in <module>

          import MoransI_Increment as MI

     File "c:\program files (x86)\arcgis\desktop10.2\ArcToolbox\Scripts

\MoransI_Increment.py", line 24, in <module>

          import pylab as PYLAB

     File "C:\Python27\ArcGIS10.2\lib\site-packages\pylab.py", line 1, in <module>

          from matplotlib.pylab import *

     File "C:\Python27\ArcGIS10.2\lib\site-packages\matplotlib\__init__.py", line

134, in <module>

          from matplotlib.rcsetup import (defaultParams,

     File "C:\Python27\ArcGIS10.2\lib\site-packages\matplotlib\rcsetup.py", line 18,

in <module>

          from matplotlib.fontconfig_pattern import parse_fontconfig_pattern

     File "C:\Python27\ArcGIS10.2\lib\site-packages\matplotlib

\fontconfig_pattern.py", line 23, in <module>

          from matplotlib.pyparsing import Literal, ZeroOrMore, \

     File "C:\Python27\ArcGIS10.2\lib\site-packages\matplotlib\pyparsing.py", line

71, in <module>

          import xml.sax.saxutils

     File "C:\Users\eagle\AppData\Local\Continuum\Anaconda\Lib\xml\sax

\saxutils.py", line 6, in <module>

          import os, urlparse, urllib, types

     File "C:\Users\eagle\AppData\Local\Continuum\Anaconda\Lib\urllib.py", line

26, in <module>

          import socet

     File "C:\Users\eagle\AppData\Local\Continuum\Anaconda\Lib\socket.py", line

47, in <module>

          import _socket

ImportError: DLL load failed: %1 is not a valid Win32 application.

So here's what confuses me. Why is it summoning a 32 bit DLL if I have 64 bit background geoprocessing installed?

Ideally I would like to keep Anaconda on my system.  Is there a way for me to point ArcMap back to the 32 bit interpreter for the purposes of the toolbox scripts?

Thanks for any assistance!

0 Kudos
8 Replies
DanPatterson_Retired
MVP Emeritus

Try Curtis's post Fixing broken Python

or turn off background processing

0 Kudos
EricEagle
Frequent Contributor

Ugh since I don't have admin rights on this machine, this is a half a day process probably.  I can't imagine there isn't a couple registry settings here and there I couldn't change.

0 Kudos
GregoryBrunner
Esri Contributor

How are you connecting arcpy to Anaconda? I just wrote this post today about connecting arcpy (in ArcGIS Pro) to Jupyter/Anaconda: Connecting Arcpy to Your Jupyter Notebook. Let me know.

EricEagle
Frequent Contributor

Gregory,

I just copied the .pth file from ArcGIS's 64 bit python folder to the Anaconda site packages folder.  And I made sure all 3 paths (anaconda 64, ArcGIS python 32, ArcGIS python 64) were in my PATH.

0 Kudos
GregoryBrunner
Esri Contributor

Did it work. IF not, check out here (arcgis desktop - How to get arcpy to work with Anaconda? - Geographic Information Systems Stack Exch... ). If you go to C:\Python27\ArcGISx6410.2\Lib\site-packages there should be a file called DTBGGP64.pth. Copy this file and put it in the Anaconda path.

EricEagle
Frequent Contributor

Greg, yeah, it worked fine.  Calling arcpy from anaconda worked just fine.  However, when anaconda was registered as my default interpreter and included in my path, it broke a number of spatial statistics routines.

What i've done in the meanwhile is uninstalled everything, reinstalled, and installed Anaconda without making it the default interpreter.  I'm using a script from here:

GitHub - JamesRamm/archook: Searches the system for arcgis and makes arcpy available to python (rega...

to basically go out and look for arcpy on each run.

curtvprice
MVP Esteemed Contributor

The question wasn't directly answered:

Why is it summoning a 32 bit DLL if I have 64 bit background geoprocessing installed?

The reason this happens is because when Anaconda 32 was installed, the box was checked to associate .py files to run with anaconda's x32 python when double-clicked. These file associations can only be changed with elevated access. The fix (noted correctly above) is to direct the Anaconda installer NOT to make it the default Python.

I'm really glad the 10.4 Python 2.7.10 shipped with ArcGIS comes with most of the modules most of our users install Anaconda to access: pandas, netCDF4, scipy.

DanPatterson_Retired
MVP Emeritus

Except for the fact that they issued 10.4 and pro 1.2 with two different versions of python and the stack...making for interesting times until they eventually merge.  Perhaps python 3.5 and numpy 1.10 (and its siblings) will be in the next major release

0 Kudos