【发布时间】:2014-11-11 14:15:21
【问题描述】:
我编写了一个程序,我尝试使用 PyInstaller 将其转换为可执行文件。 Pyinstaller 似乎已经完成,没有任何错误,我最终在 /dist/my_program 中得到了一个应用程序。但是,当我尝试运行该应用程序时,控制台窗口会闪烁一秒钟并带有回溯:
编辑:我已经复制了回溯。可能有一个错误,因为我必须从屏幕截图中输入它,因为它只会闪现。
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "C:\Users\user\desktop\PyInstaller-2.1\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\matplotlib.pyplot", line 108, in <module>
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\matplotlib.backends", line 32, in pylab_setup
File "C:\Users\user\desktop\PyInstaller-2.1\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\matplotlib.backends.backend_tkagg", line 7, in <module>
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\six", line 194, in load_module
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\six", line 108, in _resolve
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\six", line 779, in _import_module
ImportError: No module named FileDialog
以下是我的代码中的导入:
import Tkinter
from tkFileDialog import askopenfilename
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import subprocess
from PIL import Image, ImageTk
import os
有谁知道这是什么原因/解决方法是什么?我推测错误是 tkFileDialog 的输入?
Edit2:当我在我的解释器 (Spyder) 中运行程序时,它运行良好,但是当我使用 PyInstaller 打包它时,生成的应用程序会出现此错误。
【问题讨论】:
标签: python python-2.7 tkinter pyinstaller