user824624
user824624

Reputation: 8056

can't execute the blender python through subprocess

My blender is at the path of '/home/abc/Destkop/blender/blender-2.78'. When command line is at the path '/home/abc/Destkop/blender/blender-2.78', executing './blender -b /home/abc/Destkop/blender/car.model' through command line is working.

I am trying to execute blender in python through subprocess, but the code doesn't work with an error "/usr/bin/python: can't open file ./blender -b /home/abc/Destkop/blender/car.model", but the path is all right

here is my code

import os
import sys
import subprocess

if __name__="__main__":
    os.chdir("/home/abc/Destkop/blender/blender-2.78")
    subprocess.Popen([sys.executable],"./blender -b /home/abc/Destkop/blender/car.m

Upvotes: 1

Views: 742

Answers (1)

Lawrence D'Oliveiro
Lawrence D'Oliveiro

Reputation: 2774

Try this:

subprocess.check_call(["./blender", "-b", "/home/abc/Destkop/blender/car.m"])

Note that the shell arg defaults to False, which means the args must be a sequence (list or tuple) of words making up the command-line, not a single command-line string.

Upvotes: 1

Related Questions