I am trying to load a couple of simple python scripts on startup for later use. I don't want to run the scripts on startup, I only want them available in the Text Editor so that I can quickly run them on demand, rather than search them out individually. I have a simple script that loads 2 scripts from a file path. It works if I run the script from the text editor or from the Python console, but the script will not run if I try to load it on startup. This is on Mac OS. Here is the script...

import bpy 

This script is in my startup scripts directory, and does not execute but errors on the first line after the import bpy. I want the 2 scripts in the file paths to appear in the Text Editor after Blender loads. I can run these 2 commands in the Python console, or run this script from the Text Editor, and the scripts will load in the Text Editor. But they will not load if I try to run this code at startup.

What is different when running this code on startup, from running it after startup?

  • $\begingroup$ How do you load the script on startup? $\endgroup$
    – Justas
    Commented Jun 28, 2019 at 19:27
  • $\begingroup$ I placed the script in my User path startup scripts directory. Its the default scripts path in /User/Library/Application Support/ . So maybe its being run too early in the startup process? Should I place it in the alternate user defined startup path? $\endgroup$
    – zippy
    Commented Jun 28, 2019 at 19:55
  • $\begingroup$ And what is the error that you get? $\endgroup$
    – Justas
    Commented Jun 28, 2019 at 20:49
  • $\begingroup$ No meaningful error message. In the startup Terminal it just prints.. File "/Users/my_name/Library/Application Support/Blender/2.80/scripts/startup/import_scripts.py", line 7, in <module> bpy.ops.text.open(filepath="/Users/my_name/Documents/Blender/scripts/modules/Camera_mover.py"). It just identifies the first line in the script, but doesn't indicate what the specific problem is. $\endgroup$
    – zippy
    Commented Jun 28, 2019 at 21:15
  • $\begingroup$ Try loading your script file from the command line: blender --python path/to/import_scripts.py $\endgroup$
    – Justas
    Commented Jun 29, 2019 at 18:20

1 Answer 1


The solution is to open a script in Blender's Text Editor - this creates a text data block for the scene, which is saved with the scene. Do this on the fresh Default Blender scene to open scripts in the default New Scene, then re-save the scene as Default. If you want specific scripts available for a specific scene, just open those scripts as data blocks for that scene and save it.

This is not quite a decent solution, since the entire script is saved within the blender file, which could add up to a lot of extra data, plus it exposes the script to unintentional changes. A better method would be to save each script path in a run_script command as an individual text object.

import bpy
path = "/Users/user_name/Documents/Blender/scripts/modules/script_name.py"

Then you only save these few lines in the Blender scene file and run it from the Text Editor, and the script is isolated from changes or prying eyes. It just won't work if the blender file is opened from within a different machine or file system. Its just a convenient hack until a more elegant UI solution is invented by someone.

  • 1
    $\begingroup$ nice workaround the initial issue $\endgroup$
    – Justas
    Commented Jun 29, 2019 at 23:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .