I have a Python script that I want to turn into a scripting tool in ArcGIS. Part of the script creates several SDE database connection files, creates a versions using those connection files, and then deletes the connection files.
To delete the connection files, I'm using
os.remove(connections). This works as expected in PyScripter and the Python window in ArcMap. However, when I create a scripting tool and try to run it, it returns the message, "System cannot find the path specified" in reference to this line.
I can modify the code to say
if os.path.exists(connections): os.remove(connections)
so that it will move on to the next step, but then I am left with a folder full of connection files when the tool is finished running.
I tried arcpy's Delete, but got Error 000601 that it may be locked by another application. I found this bug which says that this is a bug with arcpy.Delete_management in ArcMap 10.2.1 (which I am using), and suggests using os.remove() instead.