I'm learning blender and want to create my own module with a custom UI. I'm stuck at the gate just trying to import Blender to run through independent python scripts:

import subprocess

bPath = "C:\Program Files\Blender Foundation\Blender\blender.exe"

subprocess.run([bPath, "--background", "--python", "myScript.py"])

All that's in myScript.py for testing is:

import bpy


All I want to do first is load up a blender render window from Python that makes the cube, ideally one stripped of the interface. I can figure the rest out from there.

My error is

FileNotFoundError: [WinError 2] The system cannot find the file specified

Any help would be much appreciated.

FileNotFoundError: [WinError 2] The system cannot find the file specified

This suggests there is a problem with the path to something in your script. I think you may need to give the absolute filepath to your myScript.py file.

Also, the "\" is an escape character in python, so if you're going to use it in the filepath to something, then you should use one of these methods:

bPath = r"C:\Program Files\Blender Foundation\Blender\blender.exe"


bPath = "C:\\Program Files\\Blender Foundation\\Blender\\blender.exe"
  • $\begingroup$ Thanks, that was my noob mistake. Is there a way to get blender to create a viewport this way? $\endgroup$ – Joshua Brewster Mar 20 '18 at 0:57
  • $\begingroup$ Opening blender with the "--background" flag means you're opening blender without a UI. From what you've said, it sounds like what you want to do is make an Addon. I recommend downloading someone else's well-made addon and having a look at their code and reading this tutorial. $\endgroup$ – doakey3 Mar 20 '18 at 1:37
  • $\begingroup$ Thanks, I was able to get a blender window to show up with the cube added. I will sort the rest out from here. $\endgroup$ – Joshua Brewster Mar 20 '18 at 1:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.