I have a blender file, proj001-master.blend, that I can modify with a Python script, proj001auto.py.

Running from the command line I enter:

blender proj001-master.blend --python proj001auto.py var1 var2 test-videos/proj001.m4v

This successfully modifies the blend file and outputs the render to proj001.m4v in the test-videos directory.

So far, so good, but this is where it gets interesting.

I have a CSV file, test.csv that has different sets of variables that I would like to run through my proj001auto.py script. To do this, I have written another Python script, master_csv_render.py.

Running from the command line I enter:

python master_csv_render.py proj001-master.blend proj001auto.py test.csv

This successfully reads and parses the CSV file to extract the variables, and creates a string, cli_line. I can print out cli_line from master_csv_render.py, and it prints out as:

blender proj001-master.blend --python proj001auto.py var1 var2 test-videos/proj001.m4v 

except the values of var1, var2, and the output file have been modified per the values in test.csv.

Once again, so far, so good, but the problem comes when I try to actually use cli_line in a subprocess command.

When I try subprocess.Popen(cli_line), I get an error message:

Traceback (most recent call last): File "master_csv_render.py", 
line 32, in subprocess.Popen(cli_line) File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", 
line 394, in init errread, errwrite) File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", 
line 1047, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory

I have tried putting quotes around each part of cli_line, and I have tried it with and without commas, but I still get error messages.

When I try the simplest possible version, subprocess.Popen("blender", "proj001-master.blend"), I still get an error message:

Traceback (most recent call last): File "master_csv_render.py", 
line 32, in subprocess.Popen("blender", "proj001-master.blend") File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", 
line 343, in init raise TypeError("bufsize must be an integer") TypeError: bufsize must be an integer

Per How to Run blender from a python program?, this should have worked to at least launch blender and open proj001-master.blend. It obviously didn't.

Any idea how I can make the subprocess.Popen command work?

  • 1
    $\begingroup$ For code markup, select code and press code button, or ctrl-K. Python 2.7 paths look suspicious. $\endgroup$
    – batFINGER
    Sep 27, 2018 at 11:56
  • 1
    $\begingroup$ Your question is hard to read. Any command that works on itself when written in cmd should work with subprocess.popen, I use it in multiple scripts $\endgroup$
    – WhatAMesh
    Sep 27, 2018 at 12:52
  • $\begingroup$ break it down, can you change cli_line to be a text only program, if that works what if you change it to just be be blender, if that does not work can you substitute it for another GUI program. Then start adding the parameters bit by bit. I have never tried this in Python but just about every language has issues around executing mildly interesting commands that require sometimes quite bizarre work-arounds. Good luck! $\endgroup$
    – rob
    Sep 28, 2018 at 7:52


You must log in to answer this question.

Browse other questions tagged .