Select to view content in your preferred language

how to edit / import / update Python scripts in 10.1

2073
3
08-23-2012 06:48 AM
lars1
by
Emerging Contributor
I have various scripts written in ArcMap 10. I need to make the minor changes so they function in 10.1, and the script editing process has seemingly changed in significant ways. Previously in 10.0 I simply edited my script in PythonWin and saved it, then right clicked the script in ArcMap Catalog window and selected 'Import Script' to ingest the new changes. This worked fine.

Now, however, I cannot import the script once I edit (option is generally greyed out), nor can I change the script source via its Properties. The documentation tells me to right click a script, select 'Edit' (after designating my editor in Geoprocessing Options), then edit my script, and then save the script. However, these changes are not ingested / reflected when I run the script, ie its running the original and unedited version. Also, when I save the script in PythonWin, the 'Save As' dialogue box pops up and the default save location is something like 'C:\tmp\arc4B75\tmp2B11.py' which doesn't seem right to me.

At present I am generally making a new tool and add the script fresh, obviously a problem for tools with parameters. Also, at some mysterious times I can re-import the script but am not sure what triggers the ability to do this.

Lastly, during this process my PythonWin Interactive Window will display messages such as:

he file 'c:\tmp\arc4B75\tmp2B11.py' is open for editing, but
checking it for changes caused the error: The system cannot find the path specified
The file 'c:\tmp\arc58B0\tmp7517.py' is open for editing, but
checking it for changes caused the error: The system cannot find the file specified
The file 'C:\tmp\arc58B0\tmp7517.py' has re-appeared - continuing to watch for changes...
The file 'c:\tmp\arc58B0\tmp5F2.py' is open for editing, but
checking it for changes caused the error: The system cannot find the file specified


Can anyone help?

Signed,
Frustrated
Tags (2)
0 Kudos
3 Replies
RobertJones2
Regular Contributor
I have the same problem. It's pretty bad for productivity - not to mention sanity - that you can just lose your changes like this.

I'm also finding periodic crashes with the following process:

1. Right click - Edit script
2. Save changes and close notepad
3. Run tool to generate a result
4. Right click on result - Share as - Geoprocessing service
5. Crash...
0 Kudos
RobertJones2
Regular Contributor
I'm working around this by using a Python toolbox, which is a little more hassle to create:

http://resources.arcgis.com/en/help/main/10.1/index.html#//001500000022000000
0 Kudos
JoeBryant1
Frequent Contributor

For anyone else that ends up here (a decade later!), see this workaround that doesn't involve creating a Python Toolbox:

https://support.esri.com/en/technical-article/000011780

Basically, export the script first, then edit it, then import it again. You can test the script iteratively using the  "edit" function in ArcCatalog, but the script changes are saved to a temp file, and don't persist after closing the session. Copy your tested code out of the edit session once you are done developing. Then 'export' the script and add a version number to the name. Open this exported script, replace the code with what you had developed and copied out earlier, save (make sure to keep the same file name you set during the export script step) then use the "import script" function, which is available on the tool again.

Note the "import script" doesn't give you the option to select a script from the file menu after you have used "Export Script"; it will automatically import the script of the same name with no dialog or parameters.

0 Kudos