I am looking to run my python scripts using the command line. So far, I have confirmed I can open blender using the command line, and I can open a specific file as well.

The issue comes when I attempt to load a script. I seem to always get the following error:

OSError: Python file "C:\Program Files\Blender Foundation\Blender\genererate_tears.py" could not be opened: No such file or directory

I would imagine I have some missing reference, but I have not been able to find anything where someone else solved this issue.

Here's what my my command line looks like

C:\Program Files\Blender Foundation\Blender>blender -b H:\Blender3d\ScriptingPractice\scriptingpractice.blend -P genererate_tears.py


[Blender.exe] _ [blender file with script] _ [syntax to run python] _ [python script isnide of .blend file]

I have tested the rest of it without the script part, and not running it in the background, so I'm pretty confident it's just the script reference

  • 1
    $\begingroup$ Are you sure that it's not just a typo? genererate_tears.py should probably be generate_tears.py, unless the actual file name is misspelled. $\endgroup$
    – Robert Gützkow
    Nov 21, 2019 at 13:54
  • 1
    $\begingroup$ I've re-read your question and noticed that apparently you're not storing the script outside of your .blend file, because you say "[python script isnide of .blend file]". In order to for the command to work the script needs to exist at the path given in the error message. If there is no file at the C:\Program File\Blender Foundation\Blender\genererate_tears.py then Blender can't open it. You can store the script wherever you want, but then you need to use an absolute path for the -P flag (it doesn't have to be relative to Blender's install dir). $\endgroup$
    – Robert Gützkow
    Nov 21, 2019 at 14:05
  • $\begingroup$ @RobertGützkow I'm not familiar with storing the path. Would it be appropriate to save my scritp as a text file, and change the .txt to .py? $\endgroup$ Nov 21, 2019 at 15:18

1 Answer 1


Thankyou @RobertGützkow for your help!

The solution was true that I needed to have a python-specific file (outside of blender) that I could run.

To do this I

1) created a new Text.txt file 2) named it the same name as my script (optional) 3) copied and pasted the code into the text.txt file 4) rename the text.txt --> text.py 5) add the text.py file path to the code.

Here's what mine looked like : (with the command prompt pointed at blender)

C:\Program Files\Blender Foundation\Blender>

blender H:\Blender3d\ScriptingPractice\scriptingpractice.blend -P H:\Blender3d\ScriptingPractice\genererate_tears.py

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .