What is needed to run a Python script as a scheduled task on my ArcSDE server?

433
5
12-20-2012 10:01 AM
RalphForbes
New Contributor
What is needed to run a Python script as a scheduled task on a server that currently only has ArcSDE 10 and Python 2.6 installed on it?  Since the ArcSDE command "sdelocator" is no longer available starting with ArcSDE 10, I created a model on my ArcGIS 10 desktop PC and exported it to a python script to rebuild my ArcSDE-based locators.  When I try to manually run the script on the ArcSDE server, I get the "ImportError: No module named arcpy" message.  The solution (according to the help information) is to add a Desktop10.pth file containing references (paths) to the Desktop10.0\arcpy and Desktop10.0\bin folders into the C:\python26\Lib\site-packages folder but in order to access the arcpy and bin folders, it seems that will I also need to install Desktop 10 on my ArcSDE server in order to access these folders.  My infrastructure guys are concerned about having to load all this extra software on our main GIS data server just to run a script.
Tags (2)
0 Kudos
5 Replies
curtvprice
MVP Esteemed Contributor
What is needed to run a Python script as a scheduled task on a server that currently only has ArcSDE 10 and Python 2.6 installed on it?  Since the ArcSDE command "sdelocator" is no longer available starting with ArcSDE 10, I created a model on my ArcGIS 10 desktop PC and exported it to a python script to rebuild my ArcSDE-based locators.  When I try to manually run the script on the ArcSDE server, I get the "ImportError: No module named arcpy" message.  The solution (according to the help information) is to add a Desktop10.pth file containing references (paths) to the Desktop10.0\arcpy and Desktop10.0\bin folders into the C:\python26\Lib\site-packages folder but in order to access the arcpy and bin folders, it seems that will I also need to install Desktop 10 on my ArcSDE server in order to access these folders.  My infrastructure guys are concerned about having to load all this extra software on our main GIS data server just to run a script.


If you have ArcGIS Server installed on the SDE server, it should have arcpy in its install folder.
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Ralph,

Try the following:

1.  Share the following directory on your ArcGIS Desktop server:

c:\Program Files\ArcGIS\Desktop10.0

2.  Copy the Desktop10.pth to the python26\Lib\site-packages on your ArcSDE server

3.  Edit the paths in the Desktop10.pth file to include UNC paths.  Ex:

\\servername\Program Files\ArcGIS\Desktop10.0\arcpy
\\servername\Program Files\ArcGIS\Desktop10.0\bin

or, if you only shared the Desktop10.0 folder and not the Program Files folder it would be:

\\servername\Desktop10.0\arcpy
\\servername\Desktop10.0\bin

4.  Create an environment variable on your ArcSDE server called PYTHONPATH and set this to the path of the Desktop10.pth file on your ArcSDE server

Check if you are able to run the script on your ArcSDE server after these steps.
0 Kudos
RalphForbes
New Contributor
Thank you both for the replies.  I do not have ArcGIS Server installed on my ArcSDE server and I am still getting the "ImportError: No module named arcpy" error message after trying JSkinn3's solution.  Our network guys really do not care for shared folders anyway.  I think my best bet is to have Desktop 10 installed on the server.
0 Kudos
IvanBrown
New Contributor III
Yep.  That is the way that I have done it for years.  I install ArcGIS Desktop on the server that runs the script;  That way, the library that is required for geoprocessing exists where it is needed.  In a pooled ArcGIS license environment (using license manager instead of a local license), an ArcGIS Desktop license is only taken while the script is using it.  There are even geoprocessing tools for obtaining licenses and handling the case in which a license is not available.
0 Kudos
ModyBuchbinder
Esri Regular Contributor
Why no running the script on the desktop machine and make it connect to the database on the remote machine?
That way you do not have to install anything and the script will share the desktop license in case somebody else using it?

Mody
0 Kudos