AnsweredAssumed Answered

Python subprocess module and 64 bit background geoprocessing in v10.1

Question asked by csny490 on Feb 27, 2013
Latest reply on Jun 17, 2013 by csny490
I have a script that relys on the 'subprocess' module to basically run seperate instances of arcpy as a parallel process. After installing the 'ArcGIS_BackgroundGP_for_Desktop_101sp1.exe' 64-bit geoprocessing package I have both the 32-bit and 64-bit versions of Python 2.7 on my machine. Both versions of python will import and play with arcpy just fine. However, when I attempt to launch a subprocess of arcpy with a 64 bit version of Python, the subprocess script fails upon attempting to import arcpy with the following error:

C:\Python27\ArcGISx6410.1 Python Traceback Info:   File "\\snarf\am\div_lm\ds\gis\projects\lidar_hydro_all \", line 7, in <module>     import arcpy Python Error Info: <type 'exceptions.ImportError'>: DLL load failed: %1 is not a  valid Win32 application.

The subprocess call is to the 64bit version of Python, and I have verified that this is the exe that is launching under subprocess.

The subprocess call I am making is:

subprocess.Popen(['C:\\Python27\\ArcGISx6410.1\\python.exe', '\\\\snarf\\am\\div_lm\\ds\\gis\\projects\\lidar_hydro_all\\', 'C:\\csny490\\lidar_stream_build_new', '16'], shell=False)

Funny thing is that the '' script (the import arcpy part) runs just fine stand alone in 64-bit and/or 32-bit Python, but just not when called as a subprocess.

My feeling is that for 'some reason' even though I am running the script from 64-bit python and launching the subprocesses as 64-bit python, when arcpy is being imported in the 64-bit python.exe subprocess, arcpy thinks that it is in 32-bit land still...

Trying to fix things, I added a PYTHONPATH environment variable (which curiously didn't previously exist) that points to 'C:\Python27\ArcGISx6410.1', but that didn't do the trick...

I haven't uninstalled the 32-bit version of Python, but that's my next step...

Any other ideas?