Python Executable with PyInstaller - Day 28 - 30 Days of Python

preview_player
Показать описание
Day 28 - Make a sharable Python Executable via PyInstaller

In 30 Days of Python, I'll teach you the fundamentals of Python. We created this series as an introduction to programming with Python.

Why Python? It's a very popular way to writing computer programs and automations with board applications: SpaceX & NASA use it to launch rockets, Tesla with autonomous driving, Instagram as a web app backend, Intel to pilot drones/UAVs, and many many others.

What you can do with Python is nearly endless:

Run powerful web applications
Fly drones and launch rockets
Run autonomous robots like drones and self-driving cars
Build connected systems with Arduino and Raspberry PI
Automate business intelligences and perform financial analysis
Machine learning including deep learning
And many more ways
That list is fancy but don't let it scare you. Python is just a tool for writing a series of step-by-step automation rules and that's exactly what software is: a collection of rules for a computer to follow.

The right tools in the right hands can impact the world in such amazing ways.

Shakespeare had very few tools for writing plays and yet he continues to influence our entertainment despite being long gone. Creativity mixed with the right tools can transform how we do everything or why we do it.

That's why I want to teach you this tool. The world needs your creatively, your perspective, your project.

Let's do this!

00:00:00 - Welcome
00:00:50 - Setup Virtual Environment & Install PyInstaller
00:04:17 - Minimal Flask App
00:11:41 - Data Resources with PyInstaller
00:18:00 - Build Executable
00:29:21 - When to Use PyInstaller
Рекомендации по теме
Комментарии
Автор


00:00:50 - Setup Virtual Environment & Install PyInstaller
00:04:17 - Minimal Flask App
00:11:41 - Data Resources with PyInstaller
00:18:00 - Build Executable
00:29:21 - When to Use PyInstaller

CodingEntrepreneurs
Автор

This worked flawlessly, thanks a ton. I was packing my global interpreter which has all deep learning frameworks installed into a simple PyQt5 application. Total size after exe generation would be 2.5 GBs with pipenv environment . After following your method, it is an acceptable 150 MBs.

AdityalikeThe
Автор

not all steps worked for me, but i still had success with using virtual environment for the first time and got my tkinter app from 120 mb to 30 mb size! I got many "module not found" errors when using the build.ps1 file from powershell. What worked for me was running "pyinstaller --clean main.spec" inside the virtual envirnoment, removing the dot from "from .resources import..." and removing the __init__.py (wsig.py also not needed). Im not sure if using __init__.py or a package import file outside my scripts folder would have reduced the size even further but im good in the end.

virtuousleper
Автор

How to write files in the same folder from where you are executing the standalone executable?

AshishKayastha
Автор

I have used auto-py-to-exe which is GUI for Pyinstaller. I am having a different types of problem. I have created exe file from python script and exe file works in my Mac. When I move this file (with folder) to a new computer (either Windows or Mac); it does not work. The new computer even do not recognize this executable file as exe file. Any idea what the issue could be?

khanalimphdpe
Автор

How to add SQLite database in the executable? every time the executable starts, a random MEIPASS folder created if I pass my SQLite DB file as a --add-data option, my DB data are not persisted anymore... what to do in this scenario?

littlegiant
Автор

is it --name for windows as well in the powershell file? getting an error from vs code powershell extension

thedude
Автор

Hey so it's been a while since I've used Python, so forgive my ignorance. Why do I need a virtual environment? What's the harm in installing/using packages globally?

Th_RealDirtyDan
Автор

one video on docker as well...flask app with docker

mailtodanish
Автор

i have some false positives from the antivirus building my app with pyinstaller. how could i solve this?
regards

THEMRlukasMC
Автор

How to run another app from this app.
I have done the same in windows with os.system("filename.exe") but not able to do that on mac

shraddhagami
Автор

Hi, thanks for sharing the video.
I have 2 questions:
1. Is it possible to do custom build with pyinstaller? As of now it just packages entire library I have installed in Anaconda (FYI: I use Anaconda - Spyder) but my application needs only few of them
2. After first release I did some enhancements to the application. After rebuild do I need to share the entire dist folder or just the executable and manifest file with users? (FYI: I use "pyinstaller --onedir app.py" mode to build)


Thanks in Advance...
Ab

AbrahamPanicker_AB
Автор

I have a question ....why you are using wsgi.py, we can direct start Flask app....? advantages?

mailtodanish
Автор

Thank you for the videos! I am on this one and have been able to follow along perfectly until now.

Unable to find when adding binary and data files.

I have no idea how to solve this.. i tried to change the route to

\

does anyone have a suggestion as to what im doing wrong? i can't find the file path i need

leecampbell
Автор

How to add version information in exe on mac?

SunnanIRahi
Автор

How to do it for django...tried documentation got some import errors.

nischalstha
Автор

What program use to record, is insame the quality

jhoanmartinezsilva