I need a little help creating an executable python OS command for Blender (Windows and Mac). I am setting up a stand-alone blender package for a client to use. I have a python script that imports some data and I want to create an executable python script that runs OS commands to run Blender, run the python script and define the data directories.

This is a generic version of the Windows command I normally run to import the data, using the stand-alone version of Blender:

"C:\Users\username\Desktop\Package\system\blender\blender.exe" "C:\Users\username\Desktop\Package\system\version_data\CurrentVersion.blend" -P "C:\Users\username\Desktop\Package\system\version_data\BlenderScript.py" "C:\Users\username\Desktop\Package\input_data\\" -y

From my research I have worked out that I need to:

  1. import os
  2. make the directories in the command relative
  3. create an executable python file

My python experience is limited, but I believe it may be something like this:

import os

pythonDirectory = os.path.dirname(os.path.abspath(RunThisApp.exe))  # get the current dir of this file (which would be: C:\Users\username\Desktop\Package\)

os.path.join(pathDirectory, "//system\blender\blender.exe" "//system\version_data\CurrentVersion.blend" -P "//system\version_data\BlenderScript.py" "//input_data\\" -y)

However I had a look at this post and was a little fuzzy as to the best way to do this:


Then I could possibly use PyInstaller to create the python executable files. Which seems to be the simplest method suggested here:



Am I close to the correct result here? I am guessing my syntax is off. I need to make sure it works for both Windows and Mac.

It should also be noted that the separate python script I run to import data into blender (which I have been using and updating for a couple of years), refers to OS arguments to get the desired path of data to import, so I need to make sure that I maintain that connection. Here is an example:

IMPORT_DATA_FILENAME = sys.argv[4]+'data.txt' 

Any advice or input would be greatly appreciated. Chris Lee

  • $\begingroup$ Unless I am misunderstanding, this seems like more of a Python question than a Blender one. I think this would be better suited to one of the programming focused StackExchanges. $\endgroup$ May 18, 2017 at 11:01
  • $\begingroup$ You may be correct. I will do that. $\endgroup$
    – Chris Lee
    May 18, 2017 at 16:22
  • 2
    $\begingroup$ I'm voting to close this question as off-topic because this is a general Python question, not a Blender-specific one. $\endgroup$ May 18, 2017 at 18:38
  • $\begingroup$ Thank you. Is there a way I can close the question? Should I delete it, or wait? $\endgroup$
    – Chris Lee
    May 22, 2017 at 23:55
  • $\begingroup$ I posted the question over here instead: stackoverflow.com/questions/44053517/… $\endgroup$
    – Chris Lee
    May 22, 2017 at 23:56


Browse other questions tagged .