I am trying to add a Toolbox downloaded from GIS Tools | USGS Astrogeology Science Center which should be error-free. After downloading the toolbox and unzipping the file, it is showing the error message in the picture. Any help would be appreciated!
Error text:
Traceback (most recent call last):
File "<string>", line 24, in <module>
AttributeError: 'GPEnvironment' object has no attribute 'overwriteoutput'
I found a solution, not sure it should require correction and likely needs to be modified on the USGS site toolbox download. The error has cleared in ArcGIS Pro.
In the Script, I removed the line 24 that said "overwriteoutput". Now my only concern is that I don't understand what I just removed and the impact it may have on the processing tools...
This looks like a simple typo in the code. It should be 'overwriteOutput'.
When you use geoprocessing tools that output a datafile to disk, such as a feature class or file, this environment setting controls what happens if the output datafile already exists on disk. Most of the time, you just want the output datafile to be overwritten if it exists.
If you're comfortable with editing Python code, you could change it from 'overwriteoutput' to 'overwriteOutput'. But really, whoever provided you this code should change it.
In looking at the documentation, it appears that before version 2.9, using 'overwriteoutput' would not have thrown the AttributeError exception. I suspect that the programmer created this code on a < 2.9 version of Pro.
https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/env.htm
You can set whether to overwrite in Pro's Project>Options, like this (it's the first option):
I suspect that since you deleted the offending line in the Python code, whatever you choose in Project>Options will be in effect.
Thanks for the explanation, super helpful! I'll try correcting the typo and updating my Project Option in case this comes along again.