I have script that imports arcpy, then calls a python subprocess which also imports arcpy:


import arcpy
import subprocess

cmd = [r'C:\Python27\ArcGISx6410.4\python', 'test.py']


import arcpy
print 'imported!'

When I run C:\Python27\ArcGISx6410.4\python call.py, I get an import error: ImportError: DLL load failed: %1 is not a valid Win32 application.

The stack trace (full text below) suggests that the 32 bit version of ArcPy is being called. Is it possible to call a 64 bit subprocess that imports arcpy from a 64 bit process that also imports arcpy?

I'm able to run this successfully if the subprocess is called using 32 bit python. Any idea why this isn't possible using 64 bit?

Full stack trace:

File "test.py", line 1, in
import arcpy
File "c:\program files (x86)\arcgis\desktop10.4\ArcPy\arcpy__init__.py", line 22, in
from arcpy.geoprocessing import gp
File "c:\program files (x86)\arcgis\desktop10.4\ArcPy\arcpy\geoprocessing__init__.py", line 14, in from _base import *
File "c:\program files (x86)\arcgis\desktop10.4\ArcPy\arcpy\geoprocessing_b e.py", line 14, in
import arcgisscripting ImportError: DLL load failed: %1 is not a valid Win32 application.
Traceback (most recent call last):
File "call.py", line 5, in
File "C:\Python27\ArcGISx6410.4\lib\subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['C:\Python27\ArcGISx6410.4\python'
'test.py']' returned non-zero exit status 1

  • 3
    This SO question and answers may help you to understand the possible situations you could be dealing with.
    – GeoSharp
    Nov 22, 2016 at 17:34
  • 1
    Nice, thanks. The strange thing is that I definitely have x64 bit arcpy installed (am able to import it in call.py) but am getting the error in test.py. Nov 22, 2016 at 17:47


Your Answer

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