I've built Blender as a bpy-only module meaning I can call it directly from Python. I was able to run some commands, but at the moment is failing with simply opening a main file.

My code is super simple:

def hello():
   bpy.context.scene.render.engine = 'CYCLES' 

And yet I'm failing when trying to open my file:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

The interesting bit is that the same python version with the same bpy-related code runs perfectly well from console. I'm new to Python and don't understand if it's a problem with the way I use bpy from Flask or with bpy itself.

  • $\begingroup$ You cannot just run bpy outside of Blender, it's an API. It needs to run in Blender. You can start Blender, open a file and run a script. This might be helpfull: blender.stackexchange.com/questions/1365/… $\endgroup$ Commented May 21, 2020 at 8:20
  • $\begingroup$ Also see this: docs.blender.org/manual/en/latest/advanced/command_line/… $\endgroup$ Commented May 21, 2020 at 8:22
  • $\begingroup$ You'd be surprised, @MartynasŽiemys, but you definitely can. And if you read my question till the end you'd see that I do run it in bash console as bpy module. You just need to compile the module manually, which is what I did. And it actually works for some commands, but fails for others. $\endgroup$
    – yuranos
    Commented May 21, 2020 at 17:20
  • $\begingroup$ Also see: blender.stackexchange.com/questions/117200/… $\endgroup$
    – yuranos
    Commented May 21, 2020 at 17:22
  • 1
    $\begingroup$ IMO Could be made clearer in question. Picked it as bpy module re your previous question (have same issue re draco) An observation, setting scene render to cycles then opening mainfile will set render to whatever the context is of the new file's context scene won't it?. $\endgroup$
    – batFINGER
    Commented May 21, 2020 at 17:58

1 Answer 1


Haven't done much with flask, will offer this up as a suggested workaround.

Try loading the mainfile outside of @route decorated methods.

Putting the load operator in any route method also caused a segfault for me (Ubuntu 18, blender 2.90, python 3.82) Suspect a threading issue.

The following works as expected,

# batTOOLS...........

from flask import Flask
import bpy

app = Flask(__name__)

def hello_world():
    lines = []
    for o in bpy.data.objects:

    return "\n".join(lines)
  • $\begingroup$ It does work, but I'm still to figure out if it's about threading or something else. We tried to disable threading(devtalk.blender.org/t/…) and in itself it's not enough because there's another strange thing: code with app.run(threaded=False) runs Ok when I start the app as: python3.7 app.py, but it fails when I run it as: flask run. I'm new to both Python and Flask, been a JVM fun boy for a decade, so will need to research. $\endgroup$
    – yuranos
    Commented May 22, 2020 at 5:36

You must log in to answer this question.

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