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 ?
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 ?
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.