I launched Blender in a Subprocess using

blenderPath = "C:/Program Files/..."
subprocess.Popen([blenderPath, "-r", "Subprocess.blend"])

and want to execute a Blender python script now in this subprocess. Example:


How can i import execute this script?


Invoke blender with the --help option to get all available options.

In your case you might simply use the --python option to load a script. Note: The order of the arguments are given in is important.

.\blender.exe Subprocess.blend --python your_script.py


subprocess.Popen([blenderPath, , "Subprocess.blend", "--python", "your_script.py"])

This way the blended is loaded first and then the python script is executed.

Blender 2.78 (sub 0)
Usage: blender [args ...] [file] [args ...]

-P or --python 
    Run the given Python script file

    Run the given Python script text block

    Run the given expression as a Python script

Argument Parsing:
    Arguments must be separated by white space, eg:
    # blender -ba test.blend
    ...will ignore the 'a'
    # blender -b test.blend -f8
    ...will ignore '8' because there is no space between the '-f' and the frame value

Argument Order:
    Arguments are executed in the order they are given. eg:
    # blender --background test.blend --render-frame 1 --render-output '/tmp'
    ...will not render to '/tmp' because '--render-frame 1' renders before the output path is set
    # blender --background --render-output /tmp test.blend --render-frame 1
    ...will not render to '/tmp' because loading the blend-file overwrites the render output that was set
    # blender --background test.blend --render-output /tmp --render-frame 1
    ...works as expected.

By the way, I think you don't need the -r option.

    Silently register blend-file extension, then exit (Windows only)
| improve this answer | |
  • $\begingroup$ Thanks a lot. Is there a way to not load the Blender GUI when opening? $\endgroup$ – froggyman Jan 8 '17 at 6:21
  • 1
    $\begingroup$ -b or --background (it's the very first option when running blender --help) $\endgroup$ – Greg Zaal Jan 8 '17 at 7: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.