This example is a basic Hello World application. Nothing is out of the ordinary in this example.
To package this, you can use auto-py-to-exe
and use "Console Based".
- "Console Based" is needed because we need to be able to output the
print
call. If we were to use "Window Based", we would no longer have access to stdout and it would be like we were running the script as a .pyw file - in this caseprint
would error.
An auto-py-to-exe config is supplied here.
- Open a terminal in this directory (
examples/1-basic
) - Execute
auto-py-to-exe --config auto-py-to-exe-config.json
to open auto-py-to-exe with the supplied config - Click the big blue convert button at the bottom
- When done, click the big blue "OPEN OUTPUT FOLDER" to view the output exe
Run the output exe using the terminal. If you double-click on it, it will run, but the console will close immediately. Running the exe from the terminal will allow you to see the output.
To run the exe using the terminal in Windows (similar for other OS'):
- Open cmd
- cd to the directory that the exe was generated in
- Execute
main.exe
to run the executable.
Here is an example of the output:
C:\Users\USER\Repos\auto-py-to-exe\examples\1-basic\output>main.exe
Hello world
Running with Python 3.9.9 (tags/v3.9.9:ccb0e6a, Nov 15 2021, 18:08:50) [MSC v.1929 64 bit (AMD64)]