为什么pyinstaller不生成.exe文件?
我正在尝试按照这个指南将一个简单的Hello World脚本转换成.exe文件。
我的电脑是Windows Vista,使用的是AMD 64位处理器。
我安装了Python 2.6.5(Windows AMD64版本)。
我设置了PATH(如果这个词用得对的话),这样命令行就能识别Python。
我安装了UPX(Windows上似乎只有32位版本),并按照说明把upx.exe复制到了Python26文件夹里。
我安装了Pywin(Windows AMD 64 Python 2.6版本)。
我运行了Pyinstaller的Configure.py。虽然出现了一些错误信息,但似乎还是完成了。我不知道这是否是导致问题的原因,下面是我运行时的输出:
C:\Python26\Pyinstaller\branches\py26win>Configure.py
I: 从C:\Python26\Pyinstaller\branches\py26win\config.dat读取旧配置
I: 计算EXE依赖关系
I: 查找TCL/TK...
I: 正在分析C:\Python26\DLLs_tkinter.pyd
W: 无法获取文件的二进制依赖关系:
W: C:\Python26\DLLs_tkinter.pyd
W: 最近的调用回溯:
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第608行,在get Imports
return _getImports_pe(pth)
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第275行,在_get Imports_pe
importva, importsz = datadirs[1]
IndexError: 列表索引超出范围我: 正在分析C:\Python26\DLLs_ctypes.pyd
W: 无法获取文件的二进制依赖关系:
W: C:\Python26\DLLs_ctypes.pyd
W: 最近的调用回溯:
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第608行,在get Imports
return _getImports_pe(pth)
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第275行,在_get Imports_pe
importva, importsz = datadirs[1]
IndexError: 列表索引超出范围我: 正在分析C:\Python26\DLLs\select.pyd
W: 无法获取文件的二进制依赖关系:
W: C:\Python26\DLLs\select.pyd
W: 最近的调用回溯:
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第608行,在get Imports
return _getImports_pe(pth)
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第275行,在_get Imports_pe
importva, importsz = datadirs[1]
IndexError: 列表索引超出范围我: 正在分析C:\Python26\DLLs\unicodedata.pyd
W: 无法获取文件的二进制依赖关系:
W: C:\Python26\DLLs\unicodedata.pyd
W: 最近的调用回溯:
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第608行,在get Imports
return _getImports_pe(pth)
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第275行,在_get Imports_pe
importva, importsz = datadirs[1]
IndexError: 列表索引超出范围我: 正在分析C:\Python26\DLLs\bz2.pyd
W: 无法获取文件的二进制依赖关系:
W: C:\Python26\DLLs\bz2.pyd
W: 最近的调用回溯:
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第608行,在get Imports
return _getImports_pe(pth)
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第275行,在_get Imports_pe
importva, importsz = datadirs[1]
IndexError: 列表索引超出范围我: 正在分析C:\Python26\python.exe
I: C:\Python26\python.exe的依赖组件:
I: amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none
I: 正在搜索组件amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none...
I: 找到清单C:\Windows\WinSxS\Manifests\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b.manifest
I: 正在搜索文件msvcr90.dll
I: 找到文件C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcr90.dll
I: 正在搜索文件msvcp90.dll
I: 找到文件C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcp90.dll
I: 正在搜索文件msvcm90.dll
I: 找到文件C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcm90.dll
I: 添加Microsoft.VC90.CRT\Microsoft.VC90.CRT.manifest
I: 添加Microsoft.VC90.CRT\msvcr90.dll
I: 添加Microsoft.VC90.CRT\msvcp90.dll
I: 添加Microsoft.VC90.CRT\msvcm90.dll
W: 无法获取文件的二进制依赖关系:
W: C:\Python26\python.exe
W: 最近的调用回溯:
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第608行,在get Imports
return _getImports_pe(pth)
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第275行,在_get Imports_pe
importva, importsz = datadirs[1]
IndexError: 列表索引超出范围我: 正在分析C:\Windows\WinSxS\Manifests\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b.manifest
我: 正在分析C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcr90.dll
W: 无法获取文件的二进制依赖关系:
W: C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcr90.dll
W: 最近的调用回溯:
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第608行,在get Imports
return _getImports_pe(pth)
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第275行,在_get Imports_pe
importva, importsz = datadirs[1]
IndexError: 列表索引超出范围我: 正在分析C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcp90.dll
W: 无法获取文件的二进制依赖关系:
W: C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcp90.dll
W: 最近的调用回溯:
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第608行,在get Imports
return _getImports_pe(pth)
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第275行,在_get Imports_pe
importva, importsz = datadirs[1]
IndexError: 列表索引超出范围我: 正在分析C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcm90.dll
W: 无法获取文件的二进制依赖关系:
W: C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_750b37ff97f4f68b\msvcm90.dll
W: 最近的调用回溯:
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第608行,在get Imports
return _getImports_pe(pth)
文件 "C:\Python26\Pyinstaller\branches\py26win\bindepend.py",第275行,在_get Imports_pe
importva, importsz = datadirs[1]
IndexError: 列表索引超出范围我: 找不到TCL/TK
我: 正在测试Zlib...
我: ... Zlib可用
我: 正在测试设置图标和版本资源的能力...
我: ... 资源更新可用
我: 正在测试Unicode支持...
我: ... Unicode可用
我: 正在测试UPX...
我: ...UPX可用
我: 正在计算PYZ依赖关系...
我: 完成生成C:\Python26\Pyinstaller\branches\py26win\config.dat
我的Python脚本(名为Hello.py)和示例是一样的:
#!/usr/bin/env python
for i in xrange(10000):
print "Hello, World!"
这是我的BAT文件,放在同一个目录下:
set PIP=C:\Python26\Pyinstaller\branches\py26win\
python %PIP%Makespec.py --onefile --console --upx --tk Hello.py
python %PIP%Build.py Hello.spec
当我在命令提示符下运行Hello.bat时,会生成几个文件,但没有一个是.exe文件,显示的内容如下:
C:\My Files>set PIP=C:\Python26\Pyinstaller\branches\py26win\
C:\My Files>python C:\Python26\Pyinstaller\branches\py26win\Makespec.py --onefile --console --upx --tk Hello.py
写入C:\My Files\Hello.spec
现在运行Build.py来构建可执行文件C:\My Files>python C:\Python26\Pyinstaller\branches\py26win\Build.py Hello.spec
I: C:\Python26\python.exe的依赖组件:
I: amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none
最近的调用回溯:
文件 "C:\Python26\Pyinstaller\branches\py26win\Build.py",第1359行,在main(args[0], configfilename=opts.configfile)
文件 "C:\Python26\Pyinstaller\branches\py26win\Build.py",第1337行,在main
build(specfile)
文件 "C:\Python26\Pyinstaller\branches\py26win\Build.py",第1297行,在build
execfile(spec)
文件 "Hello.spec",第3行,在
pathex=['C:\My Files'])
文件 "C:\Python26\Pyinstaller\branches\py26win\Build.py",第292行,在__init__
raise ValueError, "脚本'%s'未找到" % script
ValueError: 脚本'C:\Python26\Pyinstaller\branches\py26win\support\useTK.py'未找到
我对命令提示符的知识有限,所以如果我需要在那儿做什么,请一步一步来教我。
1 个回答
在Windows系统下,pyinstaller不支持64位的Python。不过,使用32位的Python在64位环境中通常没有什么问题,所以最简单的办法就是安装并使用32位的Python。这样做还有一个好处,就是用pyinstaller生成的可执行文件可以在32位和64位的Windows上都能运行。