如何调试无法正常运行的PyInstaller版本?
我以前只使用过PyInstaller一次,它与wxPython配合使用非常简单。我目前正在尝试建立一个不同的项目。从命令行运行时,该项目运行良好。但是,在构建之后,它永远不会启动主窗口(wxPython)。
我已经在构建规范中将debug和console标志设置为True。我还添加[('v', '',
'OPTION')]
了PyInstaller手册指定的详细选项()。规格如下:
#-*-模式:python-*-
#basedir = os.path.realpath(os.path.dirname(__ file__))
basedir = os.getcwd()
#构建图标目录。
icons_toc = []
对于os.walk(os.path.join(basedir,'icons'))中的目录:
dir [2]中的图标:
icons_toc.append(
(
os.path.join('icons',图标),
os.path.join(dir [0],icon),
'数据',
)
)
a =分析(
['application.py'],
pathex = ['。','./lib','../broadpy/lib','../broadpy/vendor'],
hiddenimports = [],
hookspath =无
)
数据+ = icons_toc
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a。脚本+ [('v','','OPTION')],
a.binaries,
a.zipfiles,
数据
名称= os.path.join(
'dist','Address cleaner.exe'
),
debug = True,
strip = None,
upx =是,
控制台=真
)
app = BUNDLE(
可执行程序,
name = os.path.join('dist','Address cleaner.app')
)
现在,当我运行生成的可执行文件时,将得到以下输出:
C:\ Users \ tomas \ Dropbox \ Broadnet \ address_cleaner>“ C:\ Users \ tomas \ Dropbox \ Broadnet \ address_cleaner \ dist \ Address cleaner.exe”
_MEIPASS2为NULL
存档名称为C:\ Users \ tomas \ Dropbox \ Broadnet \ address_cleaner \ dist \ Address cleaner.exe
提取二进制文件
通过设置运行孩子的身份执行孩子的自我
创建子进程
等待子进程完成...
_MEIPASS2是C:/ Users / tomas / AppData / Local / Temp / _MEI30762 /
存档名称为C:\ Users \ tomas \ Dropbox \ Broadnet \ address_cleaner \ dist \ Address cleaner.exe
已经在孩子-跑步!
清单路径:C:/ Users / tomas / AppData / Local / Temp / _MEI30762 / Address cleaner.exe.manifest
创建激活上下文
激活上下文已激活
C:/Users/tomas/AppData/Local/Temp/_MEI30762/python27.dll
操纵环境
PYTHONPATH = C:/用户/ tomas / AppData / Local / Temp / _MEI30762; C:/用户/ tomas / Dropbox / Broadnet / address_cleaner / dist
PYTHONHOME = C:/用户/ tomas / AppData / Local / Temp / _MEI30762 /
v
#安装zipimport钩子
导入zipimport#内置
#安装了zipimport钩子
从CArchive导入模块
导入元帅#内置
提取iu
导入imp#内置
导入nt#内置
提取结构
导入_struct#内置
提取档案
安装导入挂钩
out00-PYZ.pyz
运行脚本
导入zlib#内置
导入errno#内置
导入_weakref#内置
导入_codecs#内置
导入_sre#内置
导入_collections#内置
导入运算符#内置
导入itertools#内置
导入_bisect#内置
导入_heapq#内置
导入线程#内置
导入数学#内置
导入binascii#内置
import _hashlib#从C:\ Users \ tomas \ AppData \ Local \ Temp \ _MEI30762 \ _hashlib.pyd动态加载
导入_random#内置
导入cStringIO#内置
追溯(最近一次通话):
在第65行的文件“”中
importHook中的文件“ C:\ Users \ tomas \ Downloads \ pyinstaller-2.0 \ PyInstaller \ loader \ iu.py”,行386
文件“ C:\ Users \ tomas \ Downloads \ pyinstaller-2.0 \ PyInstaller \ loader \ iu.py”,行480,在doimport中
文件“ C:\ Users \ tomas \ Dropbox \ Broadnet \ address_cleaner \ build \ pyi.win32 \ buildspec \ out00-PYZ.pyz \ win32com”,第5行,在
importHook中的文件“ C:\ Users \ tomas \ Downloads \ pyinstaller-2.0 \ PyInstaller \ loader \ iu.py”,行386
doimport中的文件“ C:\ Users \ tomas \ Downloads \ pyinstaller-2.0 \ PyInstaller \ loader \ iu.py”,行459
getmod中的文件“ C:\ Users \ tomas \ Downloads \ pyinstaller-2.0 \ PyInstaller \ loader \ iu.py”,第248行
getmod中的文件“ C:\ Users \ tomas \ Downloads \ pyinstaller-2.0 \ PyInstaller \ loader \ iu.py”,第105行
ImportError:DLL加载失败:找不到指定的模块。
RC:-1来自pyi_rth_win32comgenpy
好。
停用激活上下文
释放激活上下文
完成了
#清除__builtin __._
#清除sys.path
#清除sys.argv
#清除sys.ps1
#清除sys.ps2
#清除sys.exitfunc
#清除sys.exc_type
#清除sys.exc_value
#清除sys.exc_traceback
#清除sys.last_type
#清除sys.last_value
#清除sys.last_traceback
#清除sys.path_hooks
#清除sys.path_importer_cache
#清除sys.meta_path
#清除sys.flags
#清除sys.float_info
#恢复sys.stdin
#恢复sys.stdout
#恢复sys.stderr
#清理__main__
#cleanup [1] cStringIO
#cleanup [1] __未来__
#cleanup [1] _collections
#cleanup [1]编码
#cleanup [1]网站
#cleanup [1] atexit
#cleanup [1]关闭
#cleanup [1] _heapq
#cleanup [1] _weakref
#cleanup [1] abc
#cleanup [1] _bisect
#cleanup [1] _weakrefset
#cleanup [1]临时文件
#cleanup [1] binascii
#cleanup [1] sre_constants
#cleanup [1]集合
#cleanup [1] _codecs
#cleanup [1] _warnings
#cleanup [1]数学
#cleanup [1]运算符
#cleanup [1] fnmatch
#cleanup [1]编解码器
#cleanup [1]重新
#cleanup [1] _struct
#cleanup [1]线程
#cleanup [1]关键字
#cleanup [1]信号
#cleanup [1]随机
#cleanup [1] itertools
#cleanup [1] encodings.aliases
#cleanup [1]例外
#cleanup [1] heapq
#cleanup [1] sre_compile
#cleanup [1] _sre
#cleanup [1] _random
#cleanup [1] hashlib
#cleanup [1]二等分
#cleanup [1] sre_parse
#cleanup [1] _hashlib
#cleanup [2] copy_reg
#清理[2] iu
#cleanup [2] os.path
#cleanup [2]存档
#cleanup [2]结构
#cleanup [2] errno
#cleanup [2] imp
#cleanup [2] _abcoll
#cleanup [2] ntpath
#cleanup [2] nt
#cleanup [2]通用路径
#cleanup [2]统计
#cleanup [2] zipimport
#cleanup [2]警告
#cleanup [2] UserDict
#cleanup [2]类型
#cleanup [2] zlib
#cleanup [2]线缓存
#cleanup [2]操作系统
#cleanup [2]元帅
#清理系统
#清理__builtin__
#cleaning ints:41个未释放的int
#清理浮点数:31个未释放的浮点数
回到父母...
C:\ Users \ tomas \ Dropbox \ Broadnet \ address_cleaner \ dist \ Address cleaner.exe的释放状态
所以现在我看到iu.py有一个引发的异常,但是我仍然不知道为什么。我也发现运行我的Downloads / py-
installer文件夹中的python文件非常神秘,即使我删除了该文件夹也是如此。
因此,总结一下-我必须采取什么步骤才能弄清楚应用程序在启动时崩溃的原因?
我正在Windows 8上将PyInstaller 2.0与Python 2.7.3结合使用,因为我正在成功构建另一个项目,所以没有一个事实会导致此错误。
-
Pyinstaller有时需要在.spec文件中使用显式引用来正确打包依赖项。
有关更多信息,请参阅确保正确的导入语句,以便pyinstaller识别它们。
例如,如果关键依赖项是从您的Python模块之一外部导入的,则很容易错过关键依赖项(例如,从pyinstaller无法读取的jar或c ++文件)。
依赖行者可能是您系统地跟踪丢失的DLL的第一道防线。只需下载它,然后加载您的exe或附属的dll,以查看哪些缺少依赖项。然后,这只是追逐它们,然后将它们与.exe一起手动添加到目录中(假设打包在
一个目录中 )。附带说明一下,对于pyinstaller 2.1(python
2.7.6),我将pyi_importers.py
文件修改为至少尝试打印在导入时是麻烦者的模块:# line 409 of Pyinstaller.loader.pyi_importers.py try: module = imp.load_module(fullname, fp, filename, self._c_ext_tuple) except Exception as e: print fullname # at least tells you what module couldn't be imported raise e
然后,知道问题发生在何处,然后可以使用依赖性遍历器查明问题,以根除丢失的DLL。