推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
ChrisFreeMan
V2EX  ›  Python

有大佬知道为啥用 pyinstaller 打包 Python 写的 macOS 应用,使用参数 --onefile 打包为单个二进制文件的时候启动超级超级慢吗?🥺

  •  
  •   ChrisFreeMan · Jan 19, 2022 · 4220 views
    This topic created in 1756 days ago, the information mentioned may be changed or developed.

    --onedir 参数的时候速度正常

    10 replies  •  2022-02-11 11:21:53 +08:00
    abersheeran
    abersheeran
    Jan 19, 2022❤️2
    1
    因为它所谓的单个二进制文件其实也会先解压成目录形式,然后再启动。多了一步自然慢一些
    ChrisFreeMan
    ChrisFreeMan
    OP
    Jan 19, 2022
    2
    @abersheeran 🤔啊..那这个感觉好鸡肋啊
    abersheeran
    abersheeran
    Jan 19, 2022
    3
    @ChrisFreeMan 还有好处的。免去了你分发的时候还要告诉用户入口在哪个目录的哪个文件
    ChrisFreeMan
    ChrisFreeMan
    OP
    Jan 19, 2022
    4
    @abersheeran 搞清楚了,--onedir 情况下会自动打包成.app 形势,删除 dist 旁边的文件夹也是可以独立执行的。。我再研究一下。。
    ysc3839
    ysc3839
    Jan 19, 2022 via Android
    5
    @abersheeran macOS 的 app 本来就是一个文件夹,按理说不需要自解压吧?
    hotsymbol
    hotsymbol
    Jan 19, 2022
    6
    需要先执行 source -- active
    zachlhb
    zachlhb
    Jan 20, 2022 via iPhone
    7
    打包到文件夹,然后按照 macos 的格式做成 app 就行了
    ChrisFreeMan
    ChrisFreeMan
    OP
    Jan 20, 2022
    8
    @hotsymbol
    @zachlhb 多谢,问题已经解决了。
    ali12333
    ali12333
    Feb 11, 2022
    10
    If you specify --windowed with either option, the dist folder also contains an OS X application named myscript.app.

    所以如果你用了-w, 或者--windowed, 那么就会自动生成一个.app 的文件夹, 可以直接运行, 比 windows 要方便些, windows 还要使用 Enigma Virtual Box 将文件夹压缩成一个 exe 文件。

    -D 的启动速度快非常多, 但是 -D 的体积会比 -F 要大 2-3 倍
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1132 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 23:09 · PVG 07:09 · LAX 15:09 · JFK 18:09
    ♥ Do have faith in what you're doing.