Is ArcMap 10.1 64-bit background geoprocessing compatible with ArcGIS Server 10.1?

2848
13
Jump to solution
05-09-2013 09:39 AM
AlanStewart
Occasional Contributor
I have both installed on the same box. There are DTBGGP64.pth and a Server10.1.pth files in the C:\Python27\ArcGISx6410.1\Lib\site-packages folder. The first points to the the C:\Program Files (x86)\ArcGIS\Desktop10.1\bin64 folder and the second points to the C:\Program Files\ArcGIS\Server\bin folder. This seems to be a conflict.

When I enable background processing and debug into a Python geoprocessing task it fails when arcpy is imported. Printing sys.path reveals:

>>> sys.path: ['C:\\ARCGIS~1\\GEOPRO~1\\TGT_GP~1\\Scripts', 'C:\\ARCGIS~1\\GEOPRO~1\\TGT_GP~1\\Scripts', 'c:\\program files (x86)\\arcgis\\desktop10.1\\bin', 'c:\\program files (x86)\\arcgis\\desktop10.1\\ArcPy', 'c:\\program files (x86)\\arcgis\\desktop10.1\\ArcToolbox\\Scripts', 'C:\\arcgisserver\\geoprocessing\\TGT_GPExporter\\ExportGeoPDF.tbx', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\ARCGIS~1.1\\DLLs', 'C:\\Python27\\ARCGIS~1.1\\lib', 'C:\\Python27\\ARCGIS~1.1\\lib\\plat-win', 'C:\\Python27\\ARCGIS~1.1\\lib\\lib-tk', 'C:\\Python27\\ARCGIS~1.1\\Lib\\SITE-P~1\\PYTHON~1', 'C:\\Python27\\ARCGIS~1.1', 'C:\\Python27\\ARCGIS~1.1\\lib\\site-packages', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.1\\bin64', 'C:\\Python27\\ARCGIS~1.1\\lib\\site-packages\\win32', 'C:\\Python27\\ARCGIS~1.1\\lib\\site-packages\\win32\\lib', 'C:\\Python27\\ARCGIS~1.1\\lib\\site-packages\\Pythonwin', 'C:\\Program Files\\ArcGIS\\Server\\bin', 'C:\\Program Files\\ArcGIS\\Server\\arcpy', 'C:\\Program Files\\ArcGIS\\Server\\ArcToolbox\\Scripts']

Note that it is pointing to the 32-bit Desktop bin folder, before the 64-bit Desktop bin64 folder is pointed to. Where is all these extra path entries coming from?

I need to publish the geoprocessing task to Server. In the past we have used ArcMap on the Server box in authoring our web applications, which call a geoprocessing task. Is this not possible anymore?
0 Kudos
1 Solution

Accepted Solutions
AlanStewart
Occasional Contributor
ESRI tells me the issue also occurs when ArcMap is set to use 64-bit PythonWin as the Python editor. NIM091620 has been created to address the issue.

View solution in original post

0 Kudos
13 Replies
KevinHibma
Esri Regular Contributor
The two .PTH files are fine. 64bit BG and Server share 64bit Python.

Whats the error you get while importing arcpy?

It looks like you've done the sys.path print from the Python window in ArcMap?
Heres the output of print sys.path in the Python window. Not quite the same as yours.

>>> sys.path
['C:\\Python27\\ArcGISx6410.2', u'c:\\program files (x86)\\arcgis\\desktop10.2\\arcpy', 'C:\\QATest\\py\\pyharness', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\ArcGIS10.2\\Lib', 'C:\\Python27\\ArcGIS10.2\\DLLs', 'C:\\Python27\\ArcGIS10.2\\Lib\\lib-tk', 'c:\\gpServices\\Sanity\\queryLayer', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.2\\bin', 'C:\\Python27\\ArcGIS10.2', 'C:\\Python27\\ArcGIS10.2\\lib\\site-packages', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.2\\arcpy', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.2\\ArcToolbox\\Scripts']


Do you have Python entries in your actual PATH environment variable?
Do you have a PYTHONPATH environment variable pointing at something?
0 Kudos
AlanStewart
Occasional Contributor
The two .PTH files are fine. 64bit BG and Server share 64bit Python.


As long as any differences between the versions of the arcgisscripting.pyd files at both locations don't cause problems running the same script in Server and ArcMap BGGP64.

Whats the error you get while importing arcpy?


>>> Unhandled exception while debugging...
Traceback (most recent call last):
  File "C:\ARCGIS~1\GEOPRO~1\TGT_GP~1\Scripts\ExportGeoPdfScript.py", line 47, in <module>
    import arcpy
  File "c:\program files (x86)\arcgis\desktop10.1\ArcPy\arcpy\__init__.py", line 21, in <module>
    from arcpy.geoprocessing import gp
  File "c:\program files (x86)\arcgis\desktop10.1\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in <module>
    from _base import *
  File "c:\program files (x86)\arcgis\desktop10.1\ArcPy\arcpy\geoprocessing\_base.py", line 14, in <module>
    import arcgisscripting
ImportError: DLL load failed: %1 is not a valid Win32 application.

It looks like you've done the sys.path print from the Python window in ArcMap?


Yep, I inserted it into my script immediately before the import statement for arcpy.

Do you have Python entries in your actual PATH environment variable?
Do you have a PYTHONPATH environment variable pointing at something?


No and no.
0 Kudos
KevinHibma
Esri Regular Contributor
The arcgisscripting.pyd is the same file used in both Server and 64bit BG.

Thats the error I suspected you were getting. Its 32bit trying to call into 64bit. Some wire, somewhere has been crossed and its trying to use the wrong libraries.

Are you running a script tool out of process? If so, can you try running in process?
0 Kudos
AlanStewart
Occasional Contributor
Are you running a script tool out of process? If so, can you try running in process?


Yes, I had the 'Run Python script in process' option in the Source tab unchecked. However, checking it makes no difference.
0 Kudos
KevinHibma
Esri Regular Contributor
I'm running out of ideas....

Any chance your script is calling subprocess or multiprocess?
That is, something in your script is making threads or other processes or even doing a os.command?
0 Kudos
AlanStewart
Occasional Contributor
Any chance your script is calling subprocess or multiprocess?
That is, something in your script is making threads or other processes or even doing a os.command?


I use os.getpid(). Why would that cause a problem? I'll try it without.

Here's the entire script, up to the point where it blows up:

import sys
import string
import os
import shutil
import uuid
import platform
import getpass
import time

print("@@@@@@@@@@@@@@@@@@@@@@")
print("Python version: " + platform.python_version())
print("Python compiler: " + platform.python_compiler())
print("Python interpreter: " + string.join(platform.architecture()))

is64Bits = False
if sys.maxsize > 2**32:
    is64Bits = True

print("Is a 64 bit architecutre: %s" % is64Bits)
print("PID: %s" % os.getpid())
print("User: " + getpass.getuser())

print("sys.path: %s" % sys.path)

import arcpy

Here's the output in the PythonWin 64-bit debugger:

PythonWin 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information.
>>> @@@@@@@@@@@@@@@@@@@@@@
>>> Python version: 2.7.2
>>> Python compiler: MSC v.1500 64 bit (AMD64)
>>> Python interpreter: 64bit WindowsPE
>>> Is a 64 bit architecutre: True
>>> PID: 3036
>>> User: Alan
>>> sys.path: ['C:\\ARCGIS~1\\GEOPRO~1\\TGT_GP~1\\Scripts', 'C:\\ARCGIS~1\\GEOPRO~1\\TGT_GP~1\\Scripts', 'c:\\program files (x86)\\arcgis\\desktop10.1\\bin', 'c:\\program files (x86)\\arcgis\\desktop10.1\\ArcPy', 'c:\\program files (x86)\\arcgis\\desktop10.1\\ArcToolbox\\Scripts', 'C:\\arcgisserver\\geoprocessing\\TGT_GPExporter\\ExportGeoPDF.tbx', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\ARCGIS~1.1\\DLLs', 'C:\\Python27\\ARCGIS~1.1\\lib', 'C:\\Python27\\ARCGIS~1.1\\lib\\plat-win', 'C:\\Python27\\ARCGIS~1.1\\lib\\lib-tk', 'C:\\Python27\\ARCGIS~1.1\\Lib\\SITE-P~1\\PYTHON~1', 'C:\\Python27\\ARCGIS~1.1', 'C:\\Python27\\ARCGIS~1.1\\lib\\site-packages', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.1\\bin64', 'C:\\Python27\\ARCGIS~1.1\\lib\\site-packages\\win32', 'C:\\Python27\\ARCGIS~1.1\\lib\\site-packages\\win32\\lib', 'C:\\Python27\\ARCGIS~1.1\\lib\\site-packages\\Pythonwin', 'C:\\Program Files\\ArcGIS\\Server\\bin', 'C:\\Program Files\\ArcGIS\\Server\\arcpy', 'C:\\Program Files\\ArcGIS\\Server\\ArcToolbox\\Scripts']
>>> Unhandled exception while debugging...
Traceback (most recent call last):
  File "C:\ARCGIS~1\GEOPRO~1\TGT_GP~1\Scripts\ExportGeoPdfScript.py", line 45, in <module>
    import arcpy
  File "c:\program files (x86)\arcgis\desktop10.1\ArcPy\arcpy\__init__.py", line 21, in <module>
    from arcpy.geoprocessing import gp
  File "c:\program files (x86)\arcgis\desktop10.1\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in <module>
    from _base import *
  File "c:\program files (x86)\arcgis\desktop10.1\ArcPy\arcpy\geoprocessing\_base.py", line 14, in <module>
    import arcgisscripting
ImportError: DLL load failed: %1 is not a valid Win32 application.
[Dbg]>>>
0 Kudos
AlanStewart
Occasional Contributor
That is, something in your script is making threads or other processes or even doing a os.command?


I took out all of the imports other than sys and string and any code dependent on the removed imports. The end result is the same.
0 Kudos
AlanStewart
Occasional Contributor
I've added the BGGP64 update to another machine with only Desktop 10.1 SP1 installed and am seeing the exact same issue, so it's not the presence of ArcGIS Server that is messing things up. Both machines are Win 7.
0 Kudos
curtvprice
MVP Esteemed Contributor
Clearly you do have 32-bit paths in your sys.path that do not belong there when you are running the 64-bit python. The question is where they are coming from.

This sure looks like something you'd want to open a support incident to get to the bottom of the issue.
0 Kudos