我正在尝试使用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>任何帮助都很感激。
发布于 2014-09-27 04:55:25
我看完书就修好了,
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我将其注释掉,并将其替换为静态路径。然后,我将tga文件从Vpython复制到这个路径中。也许有一个更优雅的解决方案,但这个解决方案对我来说很好。
发布于 2016-10-19 10:13:11
我就这样修正了:
#texturePath="visual\\" --> texturePath="visual_common\\"
#texturePath = os.path.split( __file__ )[0] + "/" -->
texturePath="C:\Python27\Lib\site-packages\\visual_common\\"问候
https://stackoverflow.com/questions/26028836
复制相似问题