【问题标题】:PyInstaller 2.1 IOErrorPyInstaller 2.1 IOError
【发布时间】:2014-09-25 00:55:39
【问题描述】:

我正在尝试使用 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>

任何帮助表示赞赏。

【问题讨论】:

  • 你可以在命令输出上点右键,鼠标高亮,然后复制粘贴到这里;而不是放置这个由于输出被截断而难以解析的屏幕截图。

标签: python exe pyinstaller


【解决方案1】:

我在阅读后能够解决这个问题,

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 复制到这个路径中。可能有一个更优雅的解决方案,但这种解决方法对我来说很好。

【讨论】:

    【解决方案2】:

    我是这样解决的:

    #texturePath="visual\\" --> texturePath="visual_common\\"
    
    #texturePath = os.path.split( __file__ )[0] + "/" -->
    texturePath="C:\Python27\Lib\site-packages\\visual_common\\"
    

    问候

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-23
      • 2013-11-09
      • 2011-09-02
      • 1970-01-01
      • 2011-07-27
      相关资源
      最近更新 更多