1

I created and successfully tested a Python script tool, for which I included some validation code, in ArcGIS Pro 1.3.1.

To write the validation code I right-clicked on the Python script tool in its standard toolbox to open its Tool Properties, went to the Validation tab and clicked Open in Script Editor.

This opened IDLE, allowed me to edit the code, and after I saved and closed IDLE, clicked OK to close the Tool Properties, and ran the tool the validation that I had just set clearly worked.

Five minutes later I went to enhance the validation code using the same editing workflow but found that clicking Open in Script Editor no longer opened IDLE to allow me to edit it.

I have rebooted my machine and the Open in Script Editor button is still no longer opening IDLE.

Via comments at the time I determined that I could get a very suboptimal script editor in Notepad to work by using the Ribbon to access ANALYSIS | Geoprocessing Options to set the Script Editor to C:\Windows\System32\notepad.exe.

However, doing the same thing to try and set the Script Editor to C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\idlelib\i‌​‌​dle.pyw returns the Open in Script Editor button to doing nothing.


I few weeks later I moved to another machine which had been upgraded to ArcGIS Pro 1.4.1 and I was hoping that would fix whatever was astray but it has not.

Is there any other method that can be used to be able to always edit the validation code for a Python script tool of ArcGIS Pro by using a Python IDE better than Notepad?


I have considered re-writing the tool as a Python Toolbox (*.pyt)but the site I am working with are more comfortable using Standard Toolboxes (*.tbx) so I would like to avoid doing that.

  • That's a really good question... is the button greyed out or does nothing happen when you click it? I assume that editing a script tool still opens IDLE so the external program is not the issue, should this be the case it might have to raised with Esri support. Can you edit/create the validator for tools that don't currently have one or is unmodified? Can you copy the script tool to a fresh toolbox and try there... perhaps the toolbox went a little funny or is from an older version and no longer truly compatible. – Michael Stimson Apr 13 '17 at 4:24
  • @MichaelMiles-Stimson It's not greyed out, it just spins for a split second then stops. Right-clicking on scripts and choosing Edit with IDLE (ArcGIS Pro) still works fine. Creating a new Python script tool does not let me set tool validation for it either so it seems like IDLE is working but tool validation is failing to use it to edit the tool validation code in a scratch file like it would normally. – PolyGeo Apr 13 '17 at 4:33
  • @MichaelMiles-Stimson Copying the tool to a new toolbox does not let me edit its validation code there either. – PolyGeo Apr 13 '17 at 4:35
  • Perhaps set a different editor like gis.stackexchange.com/questions/188913/… to refresh the registry setting - I know it's for desktop but perhaps there's a similar setting in Pro... Notepad would probably do for a test but PyWin or even Notepad++ are better editors than Notepad in the long run. It could also have to do with your temp folder, the script would need to be extracted to edit then encoded back to the toolbox when saved, there could be something wrong with that process. – Michael Stimson Apr 13 '17 at 4:40
  • In desktop the validator is extracted to %tmp% for editing, the %tmp% you would get from ArcCatalog python window by typing print os.environ.get('tmp') as ArcGis creates a fresh temp for each instance inside the system temp directory called arcXXXX where XXXX is a random 4 digit hex. Whist editing the main thread is suspended and the validator is encoded back to the toolbox when the editor is closed. – Michael Stimson Apr 13 '17 at 4:46
1

A workaround for this situation, which I have not been able to resolve, is to re-write the tool so that it resides in a Python Toolbox rather than being a Python script tool in a standard toolbox.

Upgrading a second machine to ArcGIS Pro 1.4.1 shows the same problem so I am beginning to think that whatever the issue is may be related to how this enterprise performs their installs.

I know that it is not a permissions problem with the *.tbx that I am trying to edit because setting the Script Editor to C:\Windows\System32\notepad.exe enables it to be edited but in a very sub-optimal way. This dialog is reached from ANALYSIS | Geoprocessing and clicking the small arrow at its bottom right.

enter image description here


My current workaround is to:

  1. Set the Script Editor to C:\Windows\System32\notepad.exe to enable an editor to be opened
  2. Open a New File in IDLE to use as a scratch pad
  3. Open the tool Properties to its Validation tab and copy/paste the nicely formatted code from there into the IDLE window
  4. Edit in IDLE and when happy with the changes Copy them into the paste buffer
  5. Click Open in Script Editor to open Notepad with the poorly formatted code
  6. In Notepad Ctrl-A (to select all) and Ctrl-V (to paste the contents of the paste buffer and replace what was there)
  7. Save the code in Notepad, and then close Notepad
  8. Click OK to accept the changes to the tool validation
  9. Test the tool to see that its tool validation code has been changed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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