I have script that imports arcpy, then calls a python subprocess which also imports arcpy:
call.py:
import arcpy
import subprocess
cmd = [r'C:\Python27\ArcGISx6410.4\python', 'test.py']
subprocess.check_call(cmd)
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
subprocess.check_call(cmd)
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