我正在尝试使用Pyinstaller将我的GUI转换为可执行文件。 GUI使用vpython,matplotlib和一些其他标准的python库,我已经检查过我可以使用python在命令控制台中导入所有模块。我正在使用命令构建
python pyinstaller.py -p C:\Python27\Lib\site-packages GUI.py
该程序构建,但当我尝试运行它时,我得到的错误我并不理解。
Traceback (most recent call last):
File "<string>", line 7, in <module>
File "C:\Users\James\Desktop\PyInstaller-2.1\PyInstaller\loader\pyi_importers.
py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\Users\James\Desktop\PyInstaller-2.1\GUI\build\GUI\out00-PYZ.pyz\visua
l", line 4, in <module>
File "C:\Users\James\Desktop\PyInstaller-2.1\PyInstaller\loader\pyi_importers.
py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\Users\James\Desktop\PyInstaller-2.1\GUI\build\GUI\out00-PYZ.pyz\visua
l_common.create_display", line 35, in <module>
File "C:\Users\James\Desktop\PyInstaller-2.1\PyInstaller\loader\pyi_importers.
py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\Users\James\Desktop\PyInstaller-2.1\GUI\build\GUI\out00-PYZ.pyz\visua
l_common.materials", line 159, in <module>
File "C:\Users\James\Desktop\PyInstaller-2.1\GUI\build\GUI\out00-PYZ.pyz\visua
l_common.materials", line 129, in loadTGA
IOError: [Errno 2] No such file or directory: 'C:\\Users\\James\\Desktop\\PYINST
~1.1\\GUI\\dist\\GUI\\visual_common/turbulence3.tga'
swig/python detected a memory leak of type 'wxPlatformInfo *', no destructor fou
nd.
C:\Users\James\Desktop\PyInstaller-2.1\GUI\dist\GUI>
任何帮助表示感谢。
答案 0 :(得分:0)
我在阅读后能够解决这个问题,
http://osdir.com/ml/python-visualpython-user/2009-07/msg00039.html
tl; dr是在Vpython中的materials.py中有一些设置纹理路径的代码,
if hasattr(sys,'frozen') and (sys.frozen=="windows_exe" or sys.frozen=="console_exe"):
texturePath="visual\\"
else:
texturePath = os.path.split( __file__ )[0] + "/"
del sys
我对此进行了评论并将其替换为静态路径。然后我将Vpython中的tga文件复制到此路径中。可能有更优雅的解决方案,但这种解决方法对我来说很好。
答案 1 :(得分:0)
我这样修理:
#texturePath="visual\\" --> texturePath="visual_common\\"
#texturePath = os.path.split( __file__ )[0] + "/" -->
texturePath="C:\Python27\Lib\site-packages\\visual_common\\"
此致