0

i am not able to run an external script from blender python console using os.system or subprocess.run

While if i use another python file to run this script it works but not working from blender python console The blender script does not give any error but the external script is not running

import bpy
import os
import subprocess
bpy.context.scene.frame_current = 80
subprocess.run('python ScreenShotLearning111.py',shell=True)
#os.system('python ScreenShotLearning111.py')
Duarte Farrajota Ramos
  • 59,425
  • 39
  • 130
  • 187
Ali
  • 23
  • 6
  • I have absolutely no idea how scripting works in Blender but I would guess you might need to specify the path to python and/or the path to the python script. – Mark Grant Apr 04 '21 at 16:38
  • the external script 'ScreenShotLearning111.py' runs a absolutely fine if i use another python script outside of blender to run it but when the script to run external script is opened in blender then it does not work, all the scripts are in same folder, if opening a script in blender changes its path, i do not have idea about that but to my knowledge that should not matter as script runs in cmd, moreover inside blender the script does not give any error it just does not run the external script – Ali Apr 04 '21 at 17:04
  • Well as I said, I don't know how it works in Blender but there are good reasons for an application not relying on a users path. If I had written Blender I would insist on a full path to the executable at least or some strategy to trust where it is. – Mark Grant Apr 04 '21 at 17:11
  • Add check=True to subprocess.run and see if it throws an exception. Also use bpy.context.scene.frame_set(80) to set the frame; see this for why. – scurest Apr 04 '21 at 19:05

0 Answers0