2
$\begingroup$

There is now a python executable in the blender install folder, It's clearly said that it was included for subprocesses purposes (here : https://developer.blender.org/T43486)

But how can we access it through scripts ?

$\endgroup$

1 Answer 1

3
$\begingroup$

The path to access this is bpy.app.binary_path_python

The exact details on how you should run the process are up to you, and not Blender spesific.

Best try the subprocess module, but os.system will work too.

Heres a very simple example calling a Python sub-process.

import bpy
import subprocess
import time

command = (
    bpy.app.binary_path_python,
    "-c", "import time; time.sleep(2)",
    )
proc = subprocess.Popen(command)

while proc.poll() is None:
    print("Waiting...")
    time.sleep(0.1)

print("Finished with exit code %d" % proc.returncode)

For an example of how to run Python as a subprocess without locking up Blender, see this Q & A.

$\endgroup$

You must log in to answer this question.

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