Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

So, this could be the most puzzling python geoprocessor error I have ever dealt with... This problem is occurring in ArcGIS Server 9.3, Python 2.5.2

I am exposing a typical python script as a geoprocessing service. In this script, I frequently use the gp.ListFeatureClasses() method, which searches the current workspace as shown in snippet below.

import arcgisscripting
gp = arcgisscripting.create(9.3)
gp.workspace = "C:/someworkspace/mygdb.gdb" 
featureClasses = gp.ListFeatureClasses()

In the initial portion of the script, everything works as expected. But in later portions of the script, the service crashes when I call gp.workspace reporting the following error:

AttributeError: Object: Environment <workspace> not found

My initial guess was that maybe the workspace was being set to a non-existent workspace or gdb, but I have been able to verify that the workspace is always infact valid.

Digging around a bit has shown that others have experienced the same problem. However, none have been able to set the workspace AT ALL.

Has anyone ever experienced such issues?

share|improve this question

1 Answer 1

I have had this issue, and only got around it by reassigning the location for the workspace everytime I wanted to list any featureclasses

share|improve this answer
    
Thanks for the response - but that is where I getting the error. When I call gp.Workspace = 'C:/new_workspace' in mid-script I get the Object: Environment <workspace> not found error. –  user890 Nov 24 '11 at 12:48
    
Try setting gp.Workspace = null before you reset it, or simply create a string reference to the datasets env location and 'prepend' it –  Hairy Nov 24 '11 at 13:25
    
One last thing to note, is how are you licensed? Is it through a license server? Can you post the whole script up? –  Hairy Nov 24 '11 at 13:32
    
The other thing I do, differently, is pass the environment in as a variable, so it might be acting differently? I don't know, as it is flaky, but it seems to work –  Hairy Nov 24 '11 at 13:40
    
I am starting to think this is, and excuse the pun, an environment issue, as I cannot replicate it doing it the way you are, and mine works fine. Some things I would do, is to bump any license server, reinstall possibly, your instance? How are you running the script? Can you run it in IDLE? –  Hairy Nov 24 '11 at 13:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.