I have installed pysripter on my machine and am not able to run any arcpy scripts from it despite being able to import arcpy. Models that work in model builder do not transition to pyscripter here is an example of an error I got

Traceback (most recent call last):
  File "S:\Shared\1 Survey Operations\Data Management\Databases\DB\Downloads\Testing\ftof.py", line 13, in <module>
    arcpy.ImportToolbox("Model Functions")
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\__init__.py", line 124, in ImportToolbox
    return import_toolbox(input_file, module_name)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\toolbox_code.py", line 438, in import_toolbox
    toolbox = gp.createObject("Toolbox", tbxfile)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 379, in createObject
    self._gp.CreateObject(*gp_fixargs(args, True)))
IOError: The toolbox file Model Functions was not found.
  • Are you saying you exported a model to a script and are trying to run that script? Unfortunately it sounds great at first, but most often you have to go ahead and change a lot in the script for it to really work. Exporting a model usually turns more into a help to get some basic ideas, but not really into the most useful function. – BritishSteel Feb 5 '15 at 20:38
  • 1
    Sometimes it works, sometimes it does not. My experience is that once the script gets complex the exporting will mess something up and the exported script will not work. It usually only works for very simple functionality. I keep hearing that people use it as a help, to get a general idea of what classes etc. to use, and then either write their own script, or spend some time fixing the exported output. Perhaps your error is caused by something else, but that is usually my first thought when someone has to deal with an exported script that does not work. – BritishSteel Feb 5 '15 at 20:46

From there error message, it looks like you are using a custom (non-standard) toolbox.

arcpy.ImportToolbox("Model Functions")

Try finding where that custom toolbox is located. Easiest way is to right click on it and select properties. Then include the full path to it in your code and include the tbx extension.

arcpy.ImportToolbox("c:\mypathtomytoolbox\Model Functions.tbx")

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.