filmov
tv
Using Kivy and Pyinstaller to Compile an EXE in Python3 [Beginner Friendly]
![preview_player](https://i.ytimg.com/vi/edzVrpHJh90/maxresdefault.jpg)
Показать описание
Hey Everyone! Hopefully this will help a few of you out in regards to compiling an executable (.exe) with kivy apps using pyinstaller in python.
Please leave a comment letting me know if this is useful. I'm using the latest version of Python but this should work fine for any version 3.x and up, and Pyinstaller 3.1 and up.
My Steps Taken Below:
---------------------------------------------------------------------------------------------------------------------
Step 1:
Ensure you have the correct files installed etc. (kivy, pip, pyinstaller)
Step 2:
Create a project folder, with your files in like so:
Step 3:
Open a terminal in the project folder, (remember to activate your venv if you are using that).
Enter the following into the terminal, replacing 'kivy_demo' with a project name, and the path to your .py file:
Step 4 (optional):
Optional step to add a custom icon to your finished exe.
Replace details as above and add path to .ico file:
Step 5:
Now go into your project folder, for me its C:\Users\r00t\Desktop\py-project\kivy_designs\py2exe. Open the spec file and add
the below to the top:
from kivy_deps import sdl2, glew
Step 6:
Still in the spec file, add a path for your assets e.g. (.png / .kv). I wont be covering video imports in this video as there
are additional steps required for that.
You will need to add the below with the path to your assets for your program:
Tree('assets\\'),
also add the below as is with no changes:
So your spec file in the 'COLLECT' section should look similar to this, but using your path:
coll = COLLECT(exe, Tree('assets\\'),
strip=False,
upx=True,
name='kivy_test')
Step 7:
Finally we run the below command which includes all the necessary files and kivy hooks (additional files to compile exe):
The compiled package will be in your specified directory, for me its C:\Users\r00t\Desktop\py-project\kivy_designs\py2exe\distTrack: Arc North - Catch Me When I Fall (ft Sarah de Warren)
-------------------------------------------------------------------------------------------------------------------------
Music Provided By: Magic Records
Please leave a comment letting me know if this is useful. I'm using the latest version of Python but this should work fine for any version 3.x and up, and Pyinstaller 3.1 and up.
My Steps Taken Below:
---------------------------------------------------------------------------------------------------------------------
Step 1:
Ensure you have the correct files installed etc. (kivy, pip, pyinstaller)
Step 2:
Create a project folder, with your files in like so:
Step 3:
Open a terminal in the project folder, (remember to activate your venv if you are using that).
Enter the following into the terminal, replacing 'kivy_demo' with a project name, and the path to your .py file:
Step 4 (optional):
Optional step to add a custom icon to your finished exe.
Replace details as above and add path to .ico file:
Step 5:
Now go into your project folder, for me its C:\Users\r00t\Desktop\py-project\kivy_designs\py2exe. Open the spec file and add
the below to the top:
from kivy_deps import sdl2, glew
Step 6:
Still in the spec file, add a path for your assets e.g. (.png / .kv). I wont be covering video imports in this video as there
are additional steps required for that.
You will need to add the below with the path to your assets for your program:
Tree('assets\\'),
also add the below as is with no changes:
So your spec file in the 'COLLECT' section should look similar to this, but using your path:
coll = COLLECT(exe, Tree('assets\\'),
strip=False,
upx=True,
name='kivy_test')
Step 7:
Finally we run the below command which includes all the necessary files and kivy hooks (additional files to compile exe):
The compiled package will be in your specified directory, for me its C:\Users\r00t\Desktop\py-project\kivy_designs\py2exe\distTrack: Arc North - Catch Me When I Fall (ft Sarah de Warren)
-------------------------------------------------------------------------------------------------------------------------
Music Provided By: Magic Records
Комментарии