0
$\begingroup$

I am working on this code from the post: How can I run blender from command line or a python script without opening a GUI?

I am trying to open a blend file and have a script run in that blend file to do some actions.

but I get error while running this code from the above post

import bpy
import subprocess

f_path = 'C:/Users/naman/Desktop/test.blend'


code = """
import bpy

for obj in bpy.data.objects:
    print(obj.name)

"""
 
output = subprocess.check_output( f"blender '{f_path}' -b --python-expr '{code}' ", shell = 
True)
print(output.decode('UTF-8'))

Error in the Blender enter image description here

$\endgroup$
4
  • $\begingroup$ This looks like a near-duplicate of the later blender.stackexchange.com/questions/293440/… . I'll close this one, assumng the later one is more correct. If you need to expand / make adjustments, please do so, in your other post. $\endgroup$
    – Robin Betts
    May 22, 2023 at 20:29
  • $\begingroup$ I’m voting to close this question because it's a near duplicate of blender.stackexchange.com/questions/293440/… $\endgroup$
    – Robin Betts
    May 22, 2023 at 20:30
  • $\begingroup$ No, It's not entirely similar, on the link u mentioned I am asking how to open a blender subprocess and work code on it, In this post I am trying to open an existing file as subprocess, Check F_path for both the post $\endgroup$
    – NamanDeep
    May 23, 2023 at 4:01
  • $\begingroup$ Hi, @NamanDeep, Thanks for the correction This was actually flagged for the duplicate answer, given to both posts. I don't know if it helps, I deleted the copy on this post. I'll reopen your question. Sorry for any inconvenience. $\endgroup$
    – Robin Betts
    May 23, 2023 at 7:44

0

You must log in to answer this question.

Browse other questions tagged .