'GPEnvironment' object has no attribute 'extent'

2493
8
01-10-2022 08:29 AM
GB_MattPanunto_GISS
Occasional Contributor II

I am running a script on 2 different machines, both using the same ArcGIS Pro license. Machine #1 is using ArcGIS Pro v2.7.3, while machine #2 is using ArcGIS Pro v2.9.0.

The script works just fine in v2.7.3, but in v2.9.0, it throws the error: 'GPEnvironment' object has no attribute 'extent'.

There are several places in the script where I'm specifying environment settings, and it throws this GPEnvironment error at each. What could I be missing here?

0 Kudos
8 Replies
by Anonymous User
Not applicable

You could view all the attributes in the debugger by setting a breakpoint and look at what's there with:

stuff = arcpy.env

 

See if 'extent' is really there on the machine that is complaining. It is there in my 2.9.  Unless anyone else has any tips or knows where to set a setting for it... maybe needs to be reinstalled on that machine?

0 Kudos
DanPatterson
MVP Esteemed Contributor

Do you know where in your script it is called?  I can only find reference to 

GPEnvironment when referencing overwriteoutput in Production Mapping


... sort of retired...
0 Kudos
GB_MattPanunto_GISS
Occasional Contributor II

I maybe should have mentioned in my initial post, but this error only happens during the multiprocessing portion of the script. I didn't think that was an important distinction, but clearly seems to be.

With that, I think I may have stumbled upon something. Looking at the What's new in ArcGIS Pro 2.9 list, it seems this type of error is a new implementation:

GB_MattPanunto_GISS_0-1641836229383.png

 

So, I tested this out by printing a arcpy.ListEnvironments() during the multiprocessor portion for both the v2.7.3 and v2.9.0 machines, and got the same result, shown here:

GB_MattPanunto_GISS_1-1641836555862.png

It seems that most of the environment settings are missing from the multiprocessing environment. Why might that be? This suggests that they were never being set at all on the v2.7.3 machine, as that version wasn't capable of throwing errors for invalid environment names.

 

0 Kudos
Sahaja
by
New Contributor III

Kinda same happened to me. When I upgraded from v2.8 to v2.9 my script to create a multibuffer started giving an error "AttributeError: 'GPEnvironment' object has no attribute 'overwrite'"

I modified my script from this 

#Allow overwriting
arcpy.env.workspace=arcpyenv
arcpy.env.overwrite=True
arcpy.env.overwriteOutput = True

to this:

#Allow overwriting
arcpy.env.workspace=arcpyenv
arcpy.env.overwriteOutput = True

And it worked. Would be keen to know in-depth why is this the case though.

0 Kudos
MarceloRosensaft
New Contributor III

Somebody changed the game rules and didn't dare to tell us. I'm sure somebody from ESRI will jump in and explain

0 Kudos
RoseZhou2
Occasional Contributor

My script worked in ArcGIS Pro 2.7.3. After upgraded to Pro 2.8.5, got AttributeError: "GPEnvironment' object has no attribute 'Workspace'.

Any ideas?

Rose

0 Kudos
RoseZhou2
Occasional Contributor

Got it. It should be lower case "workspace".

Rose

0 Kudos
KevinGabelman
New Contributor II

Did you ever find a solution to this? When I print the current environment attributes, I get a pretty small subset *when running a static sub-class within a Script in an ArcPro Toolbox.*

['scratchGDB', 'scratchFolder', 'packageWorkspace', 'scriptWorkspace', 'addOutputsToMap', 'buildStatsAndRATForTempRaster', 'autoCancelling', 'isCancelled', 'overwriteOutput']

I am not sure what limits the environments available as a result of it being called within a Toolbox, as opposed to being called from a 'regular' Python script.

AttributeError: 'GPEnvironment' object has no attribute 'XYResolution'

 

 

0 Kudos