TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Compile Python applications into stand-alone executables

138 pointsby privacyonsecover 3 years ago

17 comments

pansa2over 3 years ago
IIRC a big issue with PyInstaller is that the built executables are really self-extracting archives, which have to write many files to disk before they can run. Compared to a real compiled executable, it’s slow and inelegant.<p>Unfortunately high-quality bundling into executables just isn’t a focus of Python (nor of any other high-level language). Personally, I’ve gone back to C++ for building command-line apps - as a developer I’d much rather be writing Python, but that’s no good if I can’t actually deliver software to users.
评论 #29442220 未加载
评论 #29440250 未加载
评论 #29440294 未加载
评论 #29440059 未加载
评论 #29440043 未加载
评论 #29441019 未加载
评论 #29440136 未加载
评论 #29441579 未加载
评论 #29460062 未加载
评论 #29439955 未加载
评论 #29440458 未加载
评论 #29440237 未加载
ZuLuuuuuuover 3 years ago
PyInstaller has been a life-saver for our work. The thing with our work is that we heavily use Python and SciPy stack but we also have quite a few GUI stuff. We preferably have all our code base in Python because our team is mostly familiar with Python. Also keeping both the GUI and the application logic in Python makes it super easy to pass around data (usually numpy arrays) which we do all the time. No server&#x2F;client architecture or marshalling needed when everything is Python.<p>And we are mostly developing internal tools, so the executable size isn&#x27;t a huge concern. But we still want an executable that can be copied from computer to computer and can be opened via a simple double-click, because not everybody in our company is a software engineer, a lot of people are just used to copying the executable to their computer and double-clicking on it to launch it. We don&#x27;t use the --onefile feature since it makes the launches slow because of the extraction step. So we have a folder with an executable and the dependencies in it.<p>PyInstaller was a very good fit for our case. Yes the size of the bundle is quite big but it does the job. And allowed us to keep our whole code base in Python.
评论 #29440789 未加载
quietbritishjimover 3 years ago
Also worth checking out: Nuitka [1]. It actually compiles your Python into machine code (albeit still making use of the CPython interpreter).<p>Despite the title, pyinstaller doesn&#x27;t really compile anything, it just bundles your bytecode and the interpreter into a binary. That&#x27;s often useful, but it&#x27;s not the same thing. You can get similar-ish results to Nuitka by combining pyinstaller with Cython but it&#x27;s quite a bit of work.<p>[1] <a href="https:&#x2F;&#x2F;nuitka.net&#x2F;" rel="nofollow">https:&#x2F;&#x2F;nuitka.net&#x2F;</a>
评论 #29440496 未加载
评论 #29440085 未加载
评论 #29439789 未加载
welderover 3 years ago
I really tried to use PyInstaller and Nuitka to deploy a Python command line [1] to Windows, Mac, and Linux users. We couldn&#x27;t get around some system dependencies like OpenSSL needing to be available and not broken on user machines. We ended up re-writing the whole program from Python into Go [2].<p>Using Go solved so many long-tail bugs for us and just simplified the whole process of shipping code to user machines.<p>Here&#x27;s the old but working build script that built both PyInstaller and Nuitka [3].<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;wakatime&#x2F;legacy-python-cli&#x2F;tree&#x2F;standalone" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;wakatime&#x2F;legacy-python-cli&#x2F;tree&#x2F;standalon...</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;wakatime&#x2F;wakatime-cli" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;wakatime&#x2F;wakatime-cli</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;wakatime&#x2F;legacy-python-cli&#x2F;blob&#x2F;standalone&#x2F;build_standalone.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;wakatime&#x2F;legacy-python-cli&#x2F;blob&#x2F;standalon...</a>
评论 #29442216 未加载
评论 #29443324 未加载
pacifikaover 3 years ago
I’ve tried all the options and my view is unless you test bundling from the start of the project you’re in for a world of hurt, either having to manually patch packages (ntlk); or produce executables that are missing dependencies.<p>It’s the main reason I’m looking at switching to Go for these kinds of apps. Python should have a working solution as part of the standard library.
评论 #29439758 未加载
评论 #29439793 未加载
kissgyorgyover 3 years ago
My favorite is the fairly new, but excellent PyOxidizer: <a href="https:&#x2F;&#x2F;github.com&#x2F;indygreg&#x2F;PyOxidizer" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;indygreg&#x2F;PyOxidizer</a><p>It&#x27;s written in rust and can embed resources and dependencies in the executable.
评论 #29439861 未加载
anakaineover 3 years ago
The most recent version of pyinstaller has been flagged in our enterprise fireeye endpoint security default rules. What happens is that pyinstaller has a folder in the python pyinstaller library directory that has 4 exes in it that are used to produce the final exe. One is called run.exe. Fireeye quarantines &#x2F; deletes these. This didn&#x27;t happen on older versions. Its a pretty big issue if these are stubs that will be flagged or if they will be compiled in with the final executable such that an application deployed to users might get flagged as malicious.
jacksonkmarleyover 3 years ago
Soon after going through the python environment selection dance (pyenv fwiw, although sometimes conda), I went through the python binary tool selection dance and ended up on pyinstaller.<p>However I eventually abandoned hope that I was on a fruitful path, and changed course for web server land, embarking on the python web framework selection dance.
评论 #29440092 未加载
ashishknitcsover 3 years ago
In role of IT manager py2exe and pyinstaller are my goto tool to make script work on machine.<p>I’m from a IT dept of a oil company not much of savvy apps mostly dull.<p>As manager have to do lots of data wrangling for this and that form of reports.<p>scripts to do jobs on machine.<p>Python is only fullstack i know. Pyinstaller is mine goto tool to build executable and make it portable across environment.
ta988over 3 years ago
I deployed a Py application (Pandas, PyQT) at work. It was horribly slow on half of the Windows machines ,likely because of the antivirus but I didn&#x27;t have admin rights to check that. It was impossible to make a single file exe because it took too long to decompress. I spent days trying to reduce all the unused files half-manually (because automated approaches kept failing). In the end I threw all of that out , rewrote the UI and deployed it as a web application on a server. Now the users are happy.
评论 #29441975 未加载
remramover 3 years ago
PSA: If you distribute this kind of software, be ready to deal with many antivirus issues. [1] has helped but it&#x27;s still a very manual and frustrating process on every release.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;hankhank10&#x2F;false-positive-malware-reporting" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;hankhank10&#x2F;false-positive-malware-reporti...</a>
评论 #29441685 未加载
zvrover 3 years ago
Repeating my comment from every time PyInstaller is being discussed:<p>One issue with PyInstaller is that, by default, it includes all dynamic libraries that the Python interpreter has on your machine. It makes sense, it needs an interpreter and collects what is needed for it to run.<p>Unfortunately this might include libreadline.so, which is licensed under GPL, making your resulting executable unable to be distributed under a proprietary license.<p>There are ways to solve this issue, but one has to search and read documentation (and code, in my case -- when I was researching it, the docs were not clear).
mark_l_watsonover 3 years ago
The ability to make self contained executables is important. LispWorks and SBCL Common Lisp make nice, compact executables which opened more use cases for me with those languages.<p>I tried pyinstaller a few years ago, but it does not support some 3rd party libraries like TensorFlow that I frequently use. That said, I like that they clearly list supported 3rd party libraries so it is a quick check if pyinstaller will work for a specific project.
Fizzadarover 3 years ago
I use pyinstaller for my Kanmail email client [1] and it’s fantastic, but at creating Mac app bundles or Windows exes. Tried making actual standalone binaries for another project and, as others have mentioned, they’re incredibly slow to startup.<p>Still, I am a huge fan of the project and it makes it possible to make webview desktop “apps” (like or hate them) with Python.<p>[1] <a href="https:&#x2F;&#x2F;kanmail.io" rel="nofollow">https:&#x2F;&#x2F;kanmail.io</a>
groundthrowerover 3 years ago
A huge Corp really wanted our app but not the cloud based SPA app we offered - they wanted “executables” with no data stored in the cloud. Ended up creating a electron app, using our SPA and django packaged with pyinstaller that fires up as a child process. Thus a local backend with SQLIte. It’s now rolled out and works great.
scaryglidersover 3 years ago
tip: Rather than using --onefile to create a single standalone executable, IMO you&#x27;re far better off creating a dist then packaging that into an Installer using Inno Setup or similar.<p>Your app will start quicker, because it won&#x27;t be a case of the &quot;single executable&quot; doing the old unzip-and-run thing every time.
评论 #29442042 未加载
fxtentacleover 3 years ago
<i>sigh</i> that&#x27;s not &quot;compiling&quot; as programmers usually use it. PyInstaller merely packages uncompiled python programs into a self-extracting archive. Cython, on the other hand, can truly compile python3 into gcc object files which are then linkable.