I'm writing an add-on for Blender. Typically to test my code I have a massive script that has all the details so it can register all the operators, UI Panels etc when I run it through the text editor.

Unfortunately, this means I have a mess of a script that has multiple classes and methods spread out. This is hard to manage and isn't great architecture. Of course in typical IDEs you would break components out into separate files, and for release you would typically bundle them in a .zip which is installed the normal way through Blender. Refactoring one script into multiple scripts at the end of production is cumbersome, and maintaining both a Blender Test script with everything and a Library for my IDE is cumbersome.

Is there a better way to write my scripts as a library without needing to reinstall it as an an addon, or making a massive conglomerate script to run in the Text Editor?

I use PyCharm because I like it, but I know of the VSC Blender Addon. I have used VSC before but I swapped to Jetbrains products because they played a bit nicer with other tools (mainly Unity.)

  • $\begingroup$ Possibly relevant: blender.stackexchange.com/questions/33603/… $\endgroup$
    – Rug
    Sep 21, 2021 at 19:48
  • $\begingroup$ I use Vscode with the Blender dev extension by Jacques Lucke and it's working pretty well (on windows at least). If you're interested make sure you follow this step by step b3d.interplanety.org/en/… $\endgroup$
    – Gorgious
    Sep 22, 2021 at 9:14
  • $\begingroup$ Cheers! If i ever try VSC again il make sure i try that out $\endgroup$
    – Rug
    Sep 22, 2021 at 21:23
  • $\begingroup$ It's pretty handy because you can launch blender directly from vscode, and the terminal persists if blender crashes. Also you can set it up so addons automatically reload when you save your file in vscode. $\endgroup$
    – Gorgious
    Sep 23, 2021 at 5:41

1 Answer 1


I'm working a large project as well. I keep my modules in project_folder/libs/. I have to manually add my libs to the path with code like this:

import sys
import os
if local_module_path not in sys.path:

This is similar to MutantBob's answer.

Of course __file__ references the current running file, so the code adds libs under that.

  • $\begingroup$ Do you still edit outside of Blender using a separate IDE? $\endgroup$
    – Rug
    Sep 21, 2021 at 21:13
  • $\begingroup$ Yes, the built-in editor is horrible. Notepad++ for heavy editing and Spyder for algorithm test and design. $\endgroup$
    – Ron Jensen
    Sep 21, 2021 at 21:27

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.