python exe

is there any way to make a python script a .exe file so that when you open it it runs the program instead of opening the code in the text editor window? would you just when you go to the save file as just at the end of it type .exe?

If just talking about for general scripting:

i’m just talking about a generic program such as something very basic like
a = input(“give me a number”)
print “your number plus 2 is”, a + 2

not really a program related to blender in any way just trying to figure out how to make a random script into an exe file

well ok i went there and downloaded it but i really don’t understand how to use it

What if you made a starting script which has the one-liner instructions like

#file: or yourscipt.bat

Double-clicking this file should start the Python script instead of loading it to editor.

I’m sorry but I don’t quite understand what you’re telling me to do.
ok i’ve figured out how to make it an executable thank you.

ok i was somewhat right i thought i figured out how to make it to where it executes itself but my problem is now that every time i try to save it blender saves it as an internal file so it won’t be able to execute by its self how do i get blender to stop making it an internal file

BLENDER has it’s own LIBRARY/MODULE for being used with itself.

yes but i already have written like 3 different small test files and saved them and they didn’t save as internal they had the option to make them internal but after i saved them and then made a new file it changed it to where all of them were internal files no matter where i saved them too and there isn’t an option to make them non-internal

Re-post that with periods and capitalization and we’ll be able to help you better.

Also, do you mean by saving it internally, the exe your compiling is being saved internally? (as a text file)

Sorry, I’ll try to use correct punctuation this time. I was just in a hurry last time. Anyway, I’ll tell you step by step what I did, and the what Blender did. Ok, I opened Blender, went to the text editor, typed in my code, and the went down to where it says text and selected the save option. Then, I chose my directory and saved it as When I opened that file it would run as a Python file and wouldn’t run Blender to achieve that. Then, when I went back in to blender to type a second Python file, just to the right of where you set your tab spacing it now said Text: Internal. Now, when I save them as .py files and try to open them it just flashes Python’s command window (The black box thing) but doesn’t run the program, and no matter what I have done so far I can’t seem to get it to stop saving them as internal files. Also, I couln’t find any selection that let’s me choose to not make it internal, but when I made the ones that would run, it had that option right above Save As.

Please, any help would be wonderful. I really would like to know how to make these to where they don’t have to be opened in blender to run.

Can you explain what is the goal you are making your script? What kind of script it is? Is it even a Blender script or just a plain Python file? Does it have to be executable, and why? With Blender do not save it as *.exe, because making it an exe is an external task, not something Blender is done for. The exe-format is a native Windows-format, and it can not be run on other mashines. To run a Python-file automatically does not mean to convert it to exe, but to start it as from a shell-script (or as a BAT-file in Windows).

Hope you are familiar starting your Python scripts writing:
When you doubleclick the, your computer actually gives a system call, like:
And if you run a script in Blender, you can start it playing like:
blender -P
Or one possibility is to save the whole project as a blend-file, and turn the logics-bricks to autostart the script. None of these uses converting the Python-file to exe, and you should avoid it, because you always can start a Python-script from command line. (Command line calls can be made starting from icon, if that is what you want)

Ok currently my goal for the script is nothing other than to make something completely irrelevant to blender. So technically I don’t have a certain goal with it. Eventually I’m wanting to start writing scripts related to blender to help me in that fashion but right now I’m just learning. Since I’m using Blender as my text editor for some reason it (i guess) “links” the file to blender and and won’t run other wise, but no i’m not very familiar with starting it that way. I’m use to the whole “save as and click the icon” to start it please help as apparently I don’t know what i’m doing. I did run into a tutorial that was trying to tell me to do it that way but everytime i did exactly what it said I just got syntax errors so maybe someone on here can help clear it up better for me thanks.

Can no one help me? Surely someone here is experienced enough that they can follow what I did and tell me how to fix it. I’ve done it a few times so there has to be a way that I can do it again. If I’m overlooking something please tell me all I’m needing is some help.

Ok, out of the 270ish views has no one been able to help me or at least take the time to try if they don’t automatically know the answer? I thought this was supposed to be a help forum and so far it isn’t looking like it.

Okay, my guess is your trying to use Blender as a generic python development environment. If you’re new to python and just starting out, try IDLE (it comes with python). If looking for a little more advanced editor (and on Windows) try Notepad++.

My guess is you’re also looking for an easy way to execute your scripts. IDLE provides this (I believe the hotkey is F5). For a little more fun, open a command line, CD to the directory with the script and type python For example:

If you’ve saved your file in c:\mypy

> cd c:\mypy\
> python

If looking to compile it so its a little more closed and distributable, then you should use the exe tools.

There are also ways to associate a .py file so that double clicking it runs the script (though once it exits, the prompt will close).

If you’re looking to do Blender python development, then that’s when its time to pull out the Blender script editor and run things with Alt-P. Note that without some work it won’t be possible to compile an exe out of Blender (may or may not be entirely possible, but I have not needed to do so). If you’re looking to compile your script and then run it from within Blender, then its possible to call exe’s from python.

I hope that didn’t sound to harsh or rude, but I was trying to hit a couple of different bases quickly. If you’ve got more questions please put 'em out there.

i dont totally remember, it has been years so check what i tell you before you believe it. python takes your raw script and compiles it into byte code i think those are auto saved as .pyc files. it only does this the first time you run the script then it uses that as a default so in effect you are rerunning what you ran last time with no changes. there is a command to force it to reload, i cant remember what it is but as i remember it had to be done for blender to see the changes.

open up the folder/directory where you installed python. there is a doc folder, look in that. it has a huge tutorial and other stuff. the answer should be in there