Now open Command Prompt as administrator and navigate to the directory we just mentioned and run the setup.py file: $ cd exampDir $ python setup.py py2exe If we were dealing with an app with a graphical UI, we would replace console with windows like so: setup(windows=) Setup(console=) # Calls setup function to indicate that we're dealing with a single console application Import math # We have to import all modules used in our program Installing py2exeįrom re import setup # Need this to handle modules import py2exe
To follow along, no advanced Python knowledge is needed, however you will have to use Windows.Ĭonverting an interpreted language code into an executable file is a practice commonly called freezing.
In this article, we'll quickly go through the basics of py2exe and troubleshoot some common issues. The most popular way to achieve this is by using the py2exe module.
exe programs on Windows.exe stands for "Executable File", which is also known as a Binary.
If you want to create a simple application and distribute it to lots of users, writing it as a short Python script is not difficult, but assumes that the users know how to run the script and have Python already installed on their machine.Įxamples like this show that there is a valid reason to convert. ← Randomly Generating Numbers.Executing Python scripts requires a lot of prerequisites like having Python installed, having a plethora of modules installed, using the command line, etc. PyInstaller looks at imports to figure out what to bundle, so it will add your other scripts just like if you were to import os or time. If your main script imports your others scripts, then yes. Will this add my other scripts? / Will this work with external Python modules? I have not currently found a situation where these are an issue, after all, they are only warnings. These warnings can be ignored in most cases. I get lots of WARNINGs when running pyinstaller Thus I recommend using 32bit python or compiling on a 32bit machine so it will work on both architectures. As with any other programs, you cannot run 64bit on 32bit but you can run 32bit on 64bit. py thus it will create a 64bit executable. You are most likely using a 64bit machine if you are asking this question to compile the. PyInstaller will create an executable with the architecture of the machine it was built with. The exe does not work on another computer This input is like this because you are using an older version of Windows. When editing the PATH variable, I can only edit the variableĪdd a ' ' to the end and then put in the folder location, then apply/save it.
Try executing python -m pip install pyinstaller in cmd. Fatal error in launcher: Unable to create process using. Go back to the PyInstaller heading, you have not installed pyinstaller, remember to test it. 'pyinstaller' is not recognized as an internal or external command If this option doesn't appear, try again or open cmd and type cd. Then hold shift and right-click in the folder, in the menu that popped up, click "Open PowerShell Window Here" or "Open command window here" for older versions of windows. To make sure it installed properly, type pyinstaller in cmd and make sure no errors appeared.Ĭreated a new folder and put your python file in it and any other modules or files it may need. PyInstaller now supports Python 2.7 - 3.7 including Python 3.7. Make sure to check the output for errors as if there are errors it would not have installed successfully. Now that pip has been set up, execute the command pip install pyinstaller in cmd. If you haven't used or setup pip before, go to my tutorial at how-to-setup-pythons-pip to setup pip.