Hi,
We have some custom GP services which were successfully working in an ArcGIS Server 10.1. ArcGIS Desktop was also available in that machine. Recently the desktop has been uninstalled and the server has been upgraded to 10.3. Now these GP services are not working. Following is the error log I got from the ArcGIS Server Manager.
Traceback (most recent call last): File "D:\arcgisserver\directories\arcgissystem\arcgisinput\hello.GPServer\extracted\v101\my_toolboxes\hello.py", line 8, in import arcpy, sys, os, datetime, glob, ConfigParser File "c:\program files\arcgis\server\arcpy\arcpy\__init__.py", line 31, in import arcpy.sa File "c:\program files\arcgis\server\arcpy\arcpy\sa\__init__.py", line 24, in from . import Functions as __Functions ImportError: cannot import name Functions Failed to execute (hello). Failed to execute (Hello).
I doubt this may be due to the installation problem with python. So I tried to import arcpy in a sample python program and got the following error:
Traceback (most recent call last):
File "module1.py", line 19, in <module>
import arcpy
File "C:\Program Files\ArcGIS\Server\arcpy\arcpy\__init__.py", line 31, in <module>
import arcpy.sa
File "C:\Program Files\ArcGIS\Server\arcpy\arcpy\sa\__init__.py", line 29, in <module>
__all__ += __ParameterClasses.__all__
AttributeError: 'module' object has no attribute '__all__'
The sys.path yields the following:
['', 'C:\\Python27\\ArcGISx6410.3\\Lib\\site-packages', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\ArcGISx6410.3\\DLLs', 'C:\\Python27\\ArcGISx6410.3\\lib', 'C:\\Python27\\ArcGISx6410.3\\lib\\plat-win', 'C:\\Python27\\ArcGISx6410.3\\lib\\lib-tk', 'C:\\Python27\\ArcGISx6410.3', 'C:\\Program Files\\ArcGIS\\Server\\bin', 'C:\\Program Files\\ArcGIS\\Server\\arcpy', 'C:\\Program Files\\ArcGIS\\Server\\ArcToolBox\\Scripts']
Can anyone help me in identifying the issue.
It seems to be failing when it's trying to import arcpy.sa. Did you have that extension licensed at 10.1 for Server, but it's not at 10.3?
When i look into the ArcGIS Server Manager, i can see that the Spatial Analyst is Authorized for the version 10.3.
Try
from arcpy.sa import *
instead of "import arcpy.sa" in your script, assuming that is what you are using to create Run and then create the GP service. Also, I'm wondering if you need a
arcpy.CheckOutExtension("spatial")
I have not created a GP service that uses sa yet, so just a stab in the dark.
from arcpy.sa import *
This also yields the same error.
My hello.py contains only the following lines of code
import sys
from arcpy.sa import *
def main():
print 'Hello world'
if __name__ == '__main__':
main()
import arcpy itself is creating the error.
C:\Python27\ArcGISx6410.3>python hello.py
Traceback (most recent call last):
File "hello.py", line 2, in <module>
from arcpy.sa import *
File "C:\Program Files\ArcGIS\Server\arcpy\arcpy\__init__.py", line 31, in <module>
import arcpy.sa
File "C:\Program Files\ArcGIS\Server\arcpy\arcpy\sa\__init__.py", line 29, in <module>
__all__ += __ParameterClasses.__all__
AttributeError: 'module' object has no attribute '__all__'
import arcpy.sa is executed from the "C:\Program Files\ArcGIS\Server\arcpy\arcpy\__init__.py", line 31
I just ran the code you have above in a python window within my pythin IDE (Wing) and had no issues. The error include the path " C:\Python27\ArcGISx6410.3>" By any chance do you have GP 64-bit background processing installed? If so, can you uninstall it?
In any case, it looks like it is a path issue.
I've checked with the GIS Server Admin and got a response that the GP 64-bit background processing is not installed in that machine.
In the server, C:\Python27, there are 3 sub folders : "ArcGIS10.1", "ArcGISx6410.1" and "ArcGISx6410.3". Only the last one have the python.exe and other related files. The remaining 2 have the only the "Lib" folder.
The sys.path yields the following paths:
C:\Python27\ArcGISx6410.3\Lib\site-packages
C:\Windows\system32\python27.zip
C:\Python27\ArcGISx6410.3\DLLs
C:\Python27\ArcGISx6410.3\lib
C:\Python27\ArcGISx6410.3\lib\plat-win
C:\Python27\ArcGISx6410.3\lib\lib-tk
C:\Python27\ArcGISx6410.3
C:\Program Files\ArcGIS\Server\bin
C:\Program Files\ArcGIS\Server\arcpy
C:\Program Files\ArcGIS\Server\ArcToolBox\Scripts