PyInstaller编译的应用程序无法启动(FileNotFoundError)

时间:2018-10-14 16:08:00

标签: python macos executable pyinstaller cairo

我正在尝试使用pyinstaller将main.py脚本转换为Mac上的可执行文件,而这样做很困难。

pyinstaller --onefile main.py似乎顺利完成,但是当我尝试启动生成的可执行文件时,出现以下消息:

Traceback (most recent call last):
  File "/Users/waterfalls/PycharmProjects/newnew/dist/main.app/Contents/Resources/__boot__.py", line 148, in <module>
    _run()
  File "/Users/waterfalls/PycharmProjects/newnew/dist/main.app/Contents/Resources/__boot__.py", line 82, in _run
    exec(compile(source, path, 'exec'), globals(), globals())
  File "/Users/waterfalls/PycharmProjects/newnew/dist/main.app/Contents/Resources/main.py", line 6, in <module>
    import cairosvg.svg
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "cairosvg/__init__.pyc", line 37, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/Users/waterfalls/PycharmProjects/newnew/dist/main.app/Contents/MacOS/VERSION'
2018-10-14 03:25:55.473 main[23382:4662269] main Error
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

它所标记的VERSION文件确实不存在。我不确定如何做到这一点

使用pyinstaller --windowed main.py构建程序会导致很多复制标志警告失败:

    15490 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/encoding/ascii.enc
15513 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/encoding/macTurkish.enc
15517 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/tm.tcl
15520 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/encoding/cp874.enc
15525 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/en_nz.msg
15528 WARNING: failed to copy flags of /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/pkgIndex.tcl
15531 WARNING: failed to copy flags of /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/comdlg.tcl
15534 WARNING: failed to copy flags of /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/msgs/sv.msg
15538 WARNING: failed to copy flags of /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/choosedir.tcl
15540 WARNING: failed to copy flags of /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/msgs/es.msg
15542 WARNING: failed to copy flags of /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/msgs/cs.msg
15544 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/de_at.msg
15546 WARNING: failed to copy flags of /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/ttk/cursors.tcl
15549 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/init.tcl
15550 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/ro.msg
15553 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/encoding/gb2312.enc
15555 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/zh_cn.msg
15557 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/encoding/shiftjis.enc
15560 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/encoding/cp850.enc
15562 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/encoding/iso8859-1.enc
15563 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/bn.msg
15565 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/sh.msg
15567 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/ms_my.msg
15569 WARNING: failed to copy flags of /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/tk.tcl
15572 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/pt.msg
15575 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/http1.0/http.tcl
15576 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/en_gb.msg
15577 WARNING: failed to copy flags of /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/ttk/menubutton.tcl
15580 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/gv_gb.msg
15582 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/es_py.msg
15583 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/tclDTrace.d
15584 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/nb.msg
15586 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/es_uy.msg
15587 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/nn.msg
15591 WARNING: failed to copy flags of /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/msgs/da.msg
15592 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/eu.msg
15594 WARNING: failed to copy flags of /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/ttk/progress.tcl
15600 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/encoding/koi8-r.enc
15601 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/fa.msg
15602 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/es_pe.msg
15603 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/encoding/macRomania.enc
15604 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/te.msg
15606 WARNING: failed to copy flags of /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/ttk/defaults.tcl
15608 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/es_ve.msg
15609 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/es_pr.msg
15611 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/msgs/id.msg
15614 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/clock.tcl
15617 WARNING: failed to copy flags of /System/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/encoding/gb2312-raw.enc

cairosvg --version让我2.2.1

python3 --version3.7.0

pyinstaller --version是3.5.dev0 + 0b6f1ec6f(试图通过更新为devbuild来解决此问题)

还有其他人经历过吗?我该怎么做才能编译可运行的可执行文件?

编辑#1:

好的,所以问题肯定出在cairosvg和pyinstaller内,因为一旦我使用该库注释掉了零件,该应用程序便成功启动并运行。我怀疑PyInstaller不会从cairo复制该捆绑包运行所需的文件,因为它们的格式不正确。

0 个答案:

没有答案