Where did the documentation go for GP error codes? I can find them in the 10.2 help but not in the current help for Desktop or Pro.
I like to use arcpy AddIDMessage method because this allows you to link your Python Geoprocessing tool validation errors and tool errors directly to Esri's help information.
You will love Esri's answer, classic and BS. See ArcGIS Pro tool reference—ArcGIS Pro | ArcGIS Desktop .
Click to expand the Appendices node and you'll see the topic about errors and warnings. Due to the number of error reference pages, they are not provided in a browsable format. Instead, enter a search query to find a particular error reference page.
Don't want to break any copyright stuff, but everything is there.
messages...? .... if you know th code range, you can make your own list and paper your walss
<SPAN class="keyword token">import</SPAN> numpy <SPAN class="keyword token">as</SPAN> np <SPAN class="keyword token">from</SPAN> arcpy <SPAN class="keyword token">import</SPAN> gp codes <SPAN class="operator token">=</SPAN> np<SPAN class="punctuation token">.</SPAN>asarray<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">(</SPAN>i<SPAN class="punctuation token">,</SPAN> gp<SPAN class="punctuation token">.</SPAN>getIDMessage<SPAN class="punctuation token">(</SPAN>i<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN><SPAN class="number token">84000</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">85000</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> vals <SPAN class="operator token">=</SPAN> np<SPAN class="punctuation token">.</SPAN>where<SPAN class="punctuation token">(</SPAN>codes<SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">!=</SPAN> <SPAN class="string token">''</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> messages <SPAN class="operator token">=</SPAN> codes<SPAN class="punctuation token">[</SPAN>vals<SPAN class="punctuation token">]</SPAN> messages<SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="comment token"># ---- first 3 messages as an example</SPAN> array<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'84001'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Reading Data....'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'84002'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Computing Results....'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'84003'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Writing Results to Output Feature Class....'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> dtype<SPAN class="operator token">=</SPAN><SPAN class="string token">'<U617'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
sabbatical/pre-retirement explorations
Here's my method. Ran this from ArcMap and Pro python.exe's to get the list.
<SPAN class="keyword token">import</SPAN> arcpy <SPAN class="keyword token">for</SPAN> k <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN><SPAN class="number token">999999</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN> dsc <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetIDMessage<SPAN class="punctuation token">(</SPAN>k<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> dsc<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"{:6d} {}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>k<SPAN class="punctuation token">,</SPAN> dsc<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">except</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">pass</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
The diff is kind of fun, note they have tried to be consistent so your error IDs will work with one code for both arcpys.
<SPAN class="operator token">--</SPAN><SPAN class="operator token">-</SPAN> a<SPAN class="operator token">/</SPAN>gpcodes_arcmap106<SPAN class="punctuation token">.</SPAN>txt <SPAN class="operator token">++</SPAN><SPAN class="operator token">+</SPAN> b<SPAN class="operator token">/</SPAN>gpcodes_pro23<SPAN class="punctuation token">.</SPAN>txt <SPAN class="operator token">-</SPAN> <SPAN class="number token">203</SPAN> <SPAN class="operator token">%</SPAN>s Cannot contain representations <SPAN class="operator token">+</SPAN> <SPAN class="number token">203</SPAN> <SPAN class="operator token">%</SPAN>s cannot contain representations <SPAN class="operator token">-</SPAN> <SPAN class="number token">357</SPAN> End type option invalid with the ArcView or ArcEditor license <SPAN class="operator token">+</SPAN> <SPAN class="number token">357</SPAN> End type option invalid with a Basic or Standard license <SPAN class="operator token">-</SPAN> <SPAN class="number token">377</SPAN> The Side type option is invalid with an ArcView or ArcEditor license <SPAN class="operator token">+</SPAN> <SPAN class="number token">377</SPAN> The Side type option is invalid with a Basic or Standard license <SPAN class="operator token">-</SPAN> <SPAN class="number token">384</SPAN> Cannot have more than <SPAN class="number token">2</SPAN> inputs with the ArcView or ArcEditor license <SPAN class="operator token">+</SPAN> <SPAN class="number token">384</SPAN> Cannot have more than <SPAN class="number token">2</SPAN> inputs with a Basic or Standard license <SPAN class="operator token">-</SPAN> <SPAN class="number token">574</SPAN> Python <SPAN class="number token">2.7</SPAN> is not installed<SPAN class="punctuation token">.</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="number token">574</SPAN> Python is not installed<SPAN class="punctuation token">.</SPAN> <SPAN class="operator token">-</SPAN> <SPAN class="number token">707</SPAN> Spatial reference of the tiling scheme does not match the spatial reference of the data frame <SPAN class="operator token">+</SPAN> <SPAN class="number token">707</SPAN> Spatial reference of the tiling scheme does not match the spatial reference of the map <SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Here's a new way to do it, appropriate for the age of Python notebooks! Run this code in an interactive window or Python notebook:
gperr = [] for k in range(120000): try: dsc = arcpy.GetIDMessage(k) if dsc: gperr.append("{:6d} {}".format(k, dsc)) except: pass for k in range(999998,1000000,1): try: dsc = arcpy.GetIDMessage(k) if dsc: gperr.append("{:6d} {}".format(k, dsc)) except: pass def gpfind(txt="parameter", maxrec=100, use_regex=False): """Search for geoprocessing error code IDs""" import re rtxt = txt if not use_regex: # simple case-insensitive search supporting * rtxt = "{}".format(txt.replace("*",".*")) elist = [e for e in gperr if re.search(rtxt,e,re.I)] if len(elist) > maxrec or len(elist) == 0: print("{} gp errors match '{}'".format(len(elist), txt)) else: print("\n".join(elist))
Then you can do this:
>>> gpfind("map extent") 87779 DataFrameObject: Error in setting map extent >>> gpfind("parameter") 138 gp error messages match 'parameter' >>> gpfind("*invalid value*") 216 Cannot execute Pivot Table--invalid value field name 60412 The value provided was an invalid value for an identifier authority. >>> gpfind("*invalid*value*") 216 Cannot execute Pivot Table--invalid value field name 738 At least one statistical result was invalid (NaN). Please check the VIF values to determine whether near perfect multicollinearity is present. 1165 Features with invalid date/time values (only includes first 30): %1 = %2. 60412 The value provided was an invalid value for an identifier authority. 60436 A logon request contained an invalid logon type value. 61246 The string contains an invalid X500 name attribute key, oid, value or delimiter.
Fixing the original formatting...
import numpy as np from arcpy import gp # ---- sample range, change as appropriate strt = 84000 end_ = 85000 codes = np.asarray([(i, gp.getIDMessage(i)) for i in range(strt, end_)]) vals = np.where(codes[:, 1] != '')[0] messages = codes[vals]messages[:3] # ---- first 3 messages as an example array([['84001', 'Reading Data....'], ['84002', 'Computing Results....'], ['84003', 'Writing Results to Output Feature Class....']], dtype='<U617')
Another variant to save all options to a txt file using ArcGIS Pro Notebook:
import arcpy # Define the output file path output_file_path = "C:/tempfolder/arcpy_messages.txt" # Open the file in write mode with open(output_file_path, "w") as file: for k in range(1000000): try: dsc = arcpy.GetIDMessage(k) if dsc: message = "{:6d} {}\n".format(k, dsc) file.write(message) except: pass print(f"Messages saved to {output_file_path}")
Even the AI chatbot says there should be a list.
Bit late to this one, but here's a quick and dirty little script that will generate a 'codes.py' file containing a dictionary you can import:
from arcpy import GetIDMessage def get_codes(start: int=0, stop: int=280265) -> dict[int, str]: # Note, only 2 codes are in the > 280265 range. We can massively speed # up this function by just grabbing them after we get the rest c = { code: msg for code in range(start, stop) if (msg := GetIDMessage(code, False)) } c[888888] = GetIDMessage(888888) c[999998] = GetIDMessage(999998) return c def write_codes(): codes = get_codes() with open('codes.py', 'wt') as fl: fl.write('IDToMessage = {\n') for code, message in codes.items(): fl.write(f" {code}: {repr(message)},\n") fl.write('}\n\n') if __name__ == '__main__': write_codes()
It seems like there's a ton of different formatting codes in the messages, sometimes '{0} ... {1}', sometimes '%s ... %d' and sometimes '%!lld! ... %s'. It took me about 10 minutes to find and replace the different styles using the standard python string formatting specs, but you mmv
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.