Select to view content in your preferred language

Unable to use arcgisscripting

1234
9
05-25-2011 06:55 AM
DanielEntzian
Emerging Contributor
Below is the first few lines of a script that I am trying to run from a web.page. I have verified that it runs fine from python but seems fail on the first use of gp when run programaticly.

At first I thought the AddToolBox method was failing due to an incorrect path but as I said everything runs fine when run directly from python.

I tried adding the line "gp.SetProduct("ArcInfo") " before the ToolBoxLoad and now it fails so it seems to be any use of gp. causing issues.

This is ArcGIS10 using Python26 and everything ran fine using the same code/scripts on a machine with ArcGIS9.3 and Python25.

Any insight would be greatly appreciated as I am officially stumped.



import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

gp.SetProduct("ArcInfo") 

gp.AddToolbox("C:/Program Files (x86)/ArcGIS/Desktop10.0/ArcToolbox/Toolboxes/Data Management Tools.tbx")
Tags (2)
0 Kudos
9 Replies
TerrySilveus
Frequent Contributor
arcpy is the python package for arcGIS10 not arcgisscripting.  I don't know however if that excludes arcgisscripting altogether.
0 Kudos
DanielEntzian
Emerging Contributor
After a bit of reading I did try switching to arcpy and got the following error...


import arcpy  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 17, in <module>    from geoprocessing import gp  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>    from _base import *  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 568, in <module>    env = GPEnvironments(gp)  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 565, in GPEnvironments    return GPEnvironment(geoprocessor)  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 521, in __init__    self._refresh()  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 523, in _refresh    envset = (set(env for env in self._gp.listEnvironments()))RuntimeError: NotInitialized
0 Kudos
TerrySilveus
Frequent Contributor
can you post your code?  you won't be using the gp object as you did in arcgisscripting the code will need to be changed.
0 Kudos
DanielEntzian
Emerging Contributor
Code shown below but "import arcpy" causes the above error when run from the web page.

import sys, string, os
import arcpy

arcpy.AddToolbox("$data_management_toolbox$")

Sections_Dissolve = "in_memory\\\\temp_table"
Sections = "$personal_geodb$" + "/Sections"
GISADMIN_Routes = "$sde_connection$" + "/" + "$sde_schema$" + ".Routes"
GISADMIN_Routes__2_ = "$sde_connection$" + "/" + "$sde_schema$" + ".Routes"

# Process: Dissolve...
arcpy.Dissolve_management(Sections, Sections_Dissolve, "NAT_RTE_ID;Cycle_Key;Org_Code;Route_No;Route_Name;Route_Description;Route_Length_Mi", "", "MULTI_PART", "DISSOLVE_LINES")

# Process: Append...
arcpy.Append_management(Sections_Dissolve, GISADMIN_Routes__2_, "NO_TEST", "ROUTE_NO 'Route Number' true true false 5 Text 0 0 ,First,#,in_memory\\\\temp_table,Route_No,-1,-1;ROUTE_NAME 'Route Name' true true false 75 Text 0 0 ,First,#,in_memory\\\\temp_table,Route_Name,-1,-1;ORG_CODE 'Org Code' true true false 2 Short 0 5 ,First,#,in_memory\\\\temp_table,Org_Code,-1,-1;NAT_RTE_ID 'NAT_RTE_ID' true true false 14 Text 0 0 ,First,#,in_memory\\\\temp_table,NAT_RTE_ID,-1,-1;ROUTE_DESCRIPTION 'Route Description' true true false 200 Text 0 0 ,First,#,in_memory\\\\temp_table,Route_Description,-1,-1;ROUTE_LENGTH_MI 'ROUTE_LENGTH_MI' true true false 8 Double 8 38 ,First,#,in_memory\\\\temp_table,Route_Length_Mi,-1,-1;CYCLEID 'CYCLEID' true true false 2 Short 0 5 ,First,#,in_memory\\\\temp_table,Cycle_Key,-1,-1;SHAPE.LEN 'SHAPE.LEN' false false true 0 Double 0 0 ,First,#", "")


0 Kudos
TerrySilveus
Frequent Contributor
I'm not real familiar with web applications in arcGIS so hopefully someone else can help with that, but is arcpy installed and in the search path so that it can import?
0 Kudos
DanielEntzian
Emerging Contributor
Yes, I can load arcpy fine from either Idle or the command prompt. I am starting to suspect a permissions issue with the entity running Python. In the case of this issue, it would be the IIS user.

The system on which this is all working is a Win 2003 Server and the problem child is a Win 2008 R2 server. Maybe there is some form of enhanced server security that is causing my woes.
0 Kudos
MathewCoyle
Honored Contributor
If arcpy is called from a server you have to have ArcGIS Server installed from what I recall.
0 Kudos
DanielEntzian
Emerging Contributor
If arcpy is called from a server you have to have ArcGIS Server installed from what I recall.


ArcGIS Server is installed. It is pretty much the same setup as the working system. That said, I do not think that would have anything to do with this situation.
0 Kudos
DanielEntzian
Emerging Contributor
In case anyone is interested, I turned on auditing for the ArcGIS folder and when I try to run my scripts I get an unsuccessful login to the FLEXnet Licensing Service. This would explain my issues since if it can not access the license then the Geoprosessor will not be able to get loaded.

Next step it to try to grant the license server access to my web app.

**EDIT - I fixed this by changing the app pools identity to a user account instead of ApplicationPoolIdentity. The latter did not have access to get the ESRI license.
0 Kudos