I'm interested in using Blender for producing images, 3d files, or calculating geometry on a server.

Can I make blender run a python script without opening a GUI?

If not, can I incorporate Blender's python API into my own python script without running a GUI?

  • 1
    $\begingroup$ also read through other questions tagged with command-line: blender.stackexchange.com/questions/tagged/command-line $\endgroup$
    – zeffii
    Jun 25, 2013 at 11:08
  • 2
    $\begingroup$ @zeffii thanks. I was aware that Blender could render from command line, but was unsure of broader usage. At this point all the command line questions deal with rendering. $\endgroup$ Jun 25, 2013 at 11:10

3 Answers 3


Command-line / subprocess

  • You can use subprocess to run blender (like any other application) from python.
  • Use the -b / --background switch to run blender in the backgroud (GUI-less).
  • Use the -P <filename> / --python <filename> switch to load desired python script.
    • Or use --python-console to run python from stdin.

Example: blender --background --python myscript.py

See: https://docs.blender.org/manual/en/latest/advanced/command_line/arguments.html

As module

This is an experimental feature and not enabled by default, but Blender can be compiled as a python module.

This allows 'bpy' to be imported from python or other applications/IDE's which embed python

  • $\begingroup$ The "compiled as a python module" link is broken $\endgroup$
    – Nathan
    Mar 26, 2019 at 15:57
  • $\begingroup$ I think these are the updated instructions for Blender 2.8. $\endgroup$
    – bluenote10
    Oct 7, 2019 at 7:03

All what Aldrik wrote, and more Blender Python API Tips and Tricks

From official Blender documentation:

For scripts that are not interactive it can end up being more efficient not to use Blenders interface at all and instead execute the script on the command line.

blender --background --python myscript.py

You might want to run this with a blend file so the script has some data to operate on.

blender myscene.blend --background --python myscript.py
  • 2
    $\begingroup$ Links can go down. Please write some parts of the link. $\endgroup$
    – Shady Puck
    Jul 15, 2016 at 19:13
  • 1
    $\begingroup$ This is the link to the official Blender API documentation, even if the link will be broken, then anyone can find documentation. Anyway, I've updated my answer. $\endgroup$
    – Ruslan L.
    Jul 15, 2016 at 20:37

For 2.79b

#blender --background --factory-startup --python $HOME/background_job.py -- \
#          --text="Hello World" \
#          --render="/tmp/hello" \
#          --save="/tmp/hello.blend"
# Notice:
# '--factory-startup' is used to avoid the user default settings from
#                     interfering with automated scene generation.
# '--' causes blender to ignore all following arguments so python can use them.
# See blender --help for details.

Not the answer you're looking for? Browse other questions tagged or ask your own question.