0

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

NamanDeep
  • 461
  • 3
  • 12
  • This looks like a near-duplicate of the later https://blender.stackexchange.com/questions/293440/how-to-run-script-in-a-new-blender-subprocess . 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. – Robin Betts May 22 '23 at 20:29
  • I’m voting to close this question because it's a near duplicate of https://blender.stackexchange.com/questions/293440/how-to-run-script-in-a-new-blender-subprocess – Robin Betts May 22 '23 at 20:30
  • 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 – NamanDeep May 23 '23 at 04:01
  • 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. – Robin Betts May 23 '23 at 07:44

0 Answers0