To learn more about the programs and imports in this lesson, check out:
Package Your App for Windows
In the folder, you’ll find another folder named after the project file—in this case,
calculator. In there, you’ll see in large number of files—including an executable file, again called
calculator. In this case, however, you may well find that the default build by PyInstaller doesn’t work correctly, and you’ll have an application which opens and closes instantly.
The logs are located in a
.kivy\ folder in your Windows user folder, which is typically on your C drive. If you take a look at the log of the failing application, you may see a warning about an inability to find a valid Window provider.
01:54 This is because there’s some tweaking needed of the PyInstaller spec file which is created when you make a project. This allows fine tuning of PyInstaller’s operation, allowing you to customize the files which are included with the distributed application.
You’ll need to edit the
calculator.spec file. On-screen, you’ll see this done using nano in Windows Terminal. You need to add the needed imports at the top of the file … followed by the code that will allow these imports to be collected into the completed PyInstaller version of the application.
02:47 Once you’ve finished editing, if you’re using nano, you can save the file with Control and O and exit with Control and X. You can now rerun PyInstaller, but this time, you direct it to the spec file, not the Python file you used earlier.
Note that you no longer need to use the
-w switch, as the spec file already has details of how you configured the output of PyInstaller. You’ll need to confirm that you want to delete the original files with Y and Enter.
You can now run the
calculator.exe file again, and this time it should work as seen on-screen. If you’d rather have PyInstaller create a single executable file, then you can pass in the
--onefile argument in addition to
-w, as seen on-screen.
05:20 As you can see on-screen, there’s now a single file which is the entire application, which can easily be distributed. In the next section of the course, you’ll take a look at packaging your app for Android.
Become a Member to join the conversation.