pyinstaller导入错误,未找到图像

时间:2015-03-06 18:57:49

标签: macos python-2.7 tkinter pyinstaller

我正在尝试为mac制作应用程序。当我使用pyinstaller在Windows机器上制作exe时,它工作正常,但是当我在mac上执行它时,文件符合,但是当执行时我得到以下错误。

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/build/new_client/out00-PYZ.pyz/FileDialog", line 11, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/build/new_client/out00-PYZ.pyz/Tkinter", line 39, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 409, in load_module
    module = imp.load_module(fullname, fp, filename, self._c_ext_tuple)
ImportError: dlopen(/var/folders/vb/vb9xryxdEz467ZADn0LL7U+++TI/-Tmp-/_MEIbvFCo2/_tkinter.so, 2): Library not loaded: @loader_path/Tcl
  Referenced from: /var/folders/vb/vb9xryxdEz467ZADn0LL7U+++TI/-Tmp-/_MEIbvFCo2/_tkinter.so
  Reason: image not found

Tkinter和TCL似乎有问题。以下是程序加载的模块。

import socket, thread, time, json, traceback, FileDialog
from functools import partial
from mtTkinter import *

1 个答案:

答案 0 :(得分:0)

我使用的是openpyxl,它在datetime.py模块中需要jdcal。隐藏的导入或任何这些pyinstaller解决方案都没有帮助,运行exe仍然会说没有找到jdcal。我使用的解决方法是将jdcal中的少数函数直接复制到openpyxl代码中的datetime.py中。然后运行pyinstaller -F program.py

它有效!不是最好的答案,但是当你试图让一个项目走出客户的大门时,它就可以了。