This Works
The following python script works when connecting to my dev ArcGIS server, from both the ArcMap python window and the IDLE python GUI/shell running on my dev workstation:
import arcpy
arcpy.env.workspace = "Database Connections/Connection to 172.20.0.XX.sde"
str(arcpy.ListFeatureClasses("*"))
Works: Prints list of all the feature classes in the Enterprise GeoDB
This Does NOT Work
The following python script, which is the same as above but aside from the env.workspace value, DOES NOT work when connecting to my prod ArcGIS server from the IDLE python GUI/shell running on that same ArcGIS server, but DOES work from the ArcMap python window on that server...
When run from ArcMap 10.2.1 python window:
import arcpy
arcpy.env.workspace = "Database Connections/Connection to 172.20.0.XX.sde"
str(arcpy.ListFeatureClasses("*"))
Works: Prints list of all the feature classes in the Enterprise GeoDB
When run from IDLE python GUI/shell:
import arcpy
arcpy.env.workspace = "Database Connections/Connection to 172.20.0.XX.sde"
str(arcpy.ListFeatureClasses("*"))
Fails: Prints 'None'
The Windows user I'm logged into the prod ArcGIS server with is an admin, but The only thing I can come up with is
Notes
Note I have tried all of the following variations when setting the workspace:
- arcpy.env.workspace = r"Database Connections\Connection to 172.20.0.49.sde"
- arcpy.env.workspace = "Database Connections\Connection to 172.20.0.49.sde"
- arcpy.env.workspace = "Database Connections" + os.sep + "Connection to 172.20.0.49.sde"
- arcpy.env.workspace = os.path.join("Database Connections", "Connection to 172.20.0.49.sde")
- Etc...
Jason, no login dialog in ArcMap. > PolyGeo, yes, step 2 of blah238's post was the solution... full path. > Neil, I had tried that, it was not finding the workspace. I would like to understand why this was happening: the IDLE python shell can't resolve or access the same relative path that the ArcMap python window can...
– FlashJordan Oct 23 '14 at 16:14