Skip to content

Instantly share code, notes, and snippets.

@osiriswrecks
Created January 12, 2023 03:27
Show Gist options
  • Save osiriswrecks/c2763f0cce3c1313f228bacd8d4714ac to your computer and use it in GitHub Desktop.
Save osiriswrecks/c2763f0cce3c1313f228bacd8d4714ac to your computer and use it in GitHub Desktop.
Accessing Blender's Python console from a terminal
'''
If you ever need to install, enable, or debug an add-on that's running on a headless Blender install
(ie, on a server like AWS Deadline), then you can run Blender's Python console from the terminal directly.
This was originally posted here: https://blender.stackexchange.com/questions/73759/install-addons-in-headless-blender, but
I'm saving in a Gist for future me and others.
First, run this in the terminal:
blender -b --python-console
Then, in Python as needed:
'''
import bpy
bpy.ops.preferences.addon_install(filepath='/home/user/testaddon.py')
bpy.ops.preferences.addon_enable(module='testaddon')
bpy.ops.wm.save_userpref()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment