推荐学习书目
› 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
a282810
V2EX  ›  Python

请教一下关于 Python 脚本打包成单一 exe 文件的问题

  •  
  •   a282810 · Jun 17, 2017 · 5227 views
    This topic created in 3430 days ago, the information mentioned may be changed or developed.

    请教一下如何把 python 脚本打包成单一 exe 文件.

    python 脚本地址:https://github.com/soimort/you-get/releases

    它的 Latest release 版本 v0.4.715 有提供 win32.exe, 我现在需要把 v0.4.750 版本打包生成 exe 文件,请教一下我需要怎么操作?

    有尝试了一下使用 pyinstaller 打包 you-get 成单一 exe 文件,使用的命令:pyinstaller -F you-get 结果生成的 you-get.exe 打开运行后报错.

    Supplement 1  ·  Jun 17, 2017
    补充一下版本信息:

    PyInstaller: 3.2.1

    Python: 3.5.3

    Platform: Windows-10-10.0.14393-SP0

    补充 you-get.exe 报错信息:

    Traceback (most recent call last):
    File "you-get", line 9, in <module>
    ImportError: No module named 'you_get'
    Failed to execute script you-get

    打包过程信息:

    E:\you-get>pyinstaller -F you-get
    116 INFO: PyInstaller: 3.2.1
    116 INFO: Python: 3.5.3
    118 INFO: Platform: Windows-10-10.0.14393-SP0
    119 INFO: wrote E:\you-get\you-get.spec
    121 INFO: UPX is not available.
    122 INFO: Extending PYTHONPATH with paths
    ['E:\\you-get', 'E:\\you-get']
    123 INFO: checking Analysis
    141 INFO: checking PYZ
    168 INFO: checking PKG
    172 INFO: Building because E:\you-get\build\you-get\you-get.exe.manifest changed
    172 INFO: Building PKG (CArchive) out00-PKG.pkg
    1995 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
    1998 INFO: Bootloader c:\users\ben\appdata\local\programs\python\python35\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
    1999 INFO: checking EXE
    2001 INFO: Rebuilding out00-EXE.toc because you-get.exe missing
    2001 INFO: Building EXE from out00-EXE.toc
    2002 INFO: Appending archive to EXE E:\you-get\dist\you-get.exe
    2016 INFO: Building EXE from out00-EXE.toc completed successfully.
    16 replies  •  2017-06-18 03:43:55 +08:00
    zjqzxc
    zjqzxc
    Jun 17, 2017
    1
    Pyinstaller 打包的 exe 在 win7 下有问题,需要 KB2999226

    如果严重强迫症,可以考虑使用 python3.4+py2exe
    llb123
    llb123
    Jun 17, 2017
    2
    试试 cxfreeze
    a282810
    a282810
    OP
    Jun 17, 2017
    3
    @zjqzxc 我的系统是个 win10 64 也需要 KB2999226 么?
    a282810
    a282810
    OP
    Jun 17, 2017
    4
    @llb123 有试用过但是不能生成单一的 exe,还包含一大推库文件,不方便使用
    TKKONE
    TKKONE
    PRO
    Jun 17, 2017
    5
    还是做成 web 服务吧,打包一不兼容、二是打包后 exe 巨大
    zjqzxc
    zjqzxc
    Jun 17, 2017
    6
    @a282810 win10 不用。

    不过这个描述即不说系统是啥,也不说报的啥错。。。。
    lmqdlr
    lmqdlr
    Jun 17, 2017
    7
    python 版本,报错信息呢。要是 python3.6 的话要用 pyinstaller 的开发版本
    a282810
    a282810
    OP
    Jun 17, 2017
    8
    @zjqzxc 已经补充信息
    a282810
    a282810
    OP
    Jun 17, 2017
    9
    @lmqdlr 已经补充信息
    FindHao
    FindHao
    Jun 17, 2017
    10
    关注一下。以前为了打包一个自己写的工具,废了好大劲,试了好多工具。。最后还是没成功。主要是 pyqt。
    coolcoffee
    coolcoffee
    Jun 17, 2017
    11
    python2 打包 exe 简直想死, 乱码问题在不同工具之间来回出现。
    Jackeriss
    Jackeriss
    Jun 17, 2017
    12
    @a282810 @FindHao 试试 py2exe 吧,也可以打包 PyQt 程序,可以参考这个教程: https://www.jackeriss.com/p/shi_yong_py2exe_da_bao_Python_cheng_xu
    yucongo
    yucongo
    Jun 17, 2017
    13
    cxfreeze 还不错,Windows 7 + Python 3.4 下打过 wxpython 包、pyqt 包,都可以用(有些第三方 python 包要用直接拷的办法),不过 cxfreeze 不支持打包成单 exe 文件。
    sfz97308
    sfz97308
    Jun 17, 2017
    14
    只用过 py2exe,不过不能打成单一 exe
    troywinter
    troywinter
    Jun 17, 2017
    15
    这个错误信息不是很明显吗? import error,说明打包时不能 import 这个包,一般都是路径的问题。
    brad9408
    brad9408
    Jun 18, 2017 via Android
    16
    用 py2exe 吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   797 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 18:58 · PVG 02:58 · LAX 10:58 · JFK 13:58
    ♥ Do have faith in what you're doing.