<legend id='XhMPZ'><style id='XhMPZ'><dir id='XhMPZ'><q id='XhMPZ'></q></dir></style></legend>

      • <bdo id='XhMPZ'></bdo><ul id='XhMPZ'></ul>
    1. <i id='XhMPZ'><tr id='XhMPZ'><dt id='XhMPZ'><q id='XhMPZ'><span id='XhMPZ'><b id='XhMPZ'><form id='XhMPZ'><ins id='XhMPZ'></ins><ul id='XhMPZ'></ul><sub id='XhMPZ'></sub></form><legend id='XhMPZ'></legend><bdo id='XhMPZ'><pre id='XhMPZ'><center id='XhMPZ'></center></pre></bdo></b><th id='XhMPZ'></th></span></q></dt></tr></i><div id='XhMPZ'><tfoot id='XhMPZ'></tfoot><dl id='XhMPZ'><fieldset id='XhMPZ'></fieldset></dl></div>

      <small id='XhMPZ'></small><noframes id='XhMPZ'>

      <tfoot id='XhMPZ'></tfoot>

      1. PyInstalled Kivy 应用程序无法在第二台机器上运行

        时间:2023-06-07
      2. <small id='VRccp'></small><noframes id='VRccp'>

        1. <i id='VRccp'><tr id='VRccp'><dt id='VRccp'><q id='VRccp'><span id='VRccp'><b id='VRccp'><form id='VRccp'><ins id='VRccp'></ins><ul id='VRccp'></ul><sub id='VRccp'></sub></form><legend id='VRccp'></legend><bdo id='VRccp'><pre id='VRccp'><center id='VRccp'></center></pre></bdo></b><th id='VRccp'></th></span></q></dt></tr></i><div id='VRccp'><tfoot id='VRccp'></tfoot><dl id='VRccp'><fieldset id='VRccp'></fieldset></dl></div>
              <bdo id='VRccp'></bdo><ul id='VRccp'></ul>

                <tbody id='VRccp'></tbody>
              • <legend id='VRccp'><style id='VRccp'><dir id='VRccp'><q id='VRccp'></q></dir></style></legend>

                1. <tfoot id='VRccp'></tfoot>
                  本文介绍了PyInstalled Kivy 应用程序无法在第二台机器上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 PyInstaller (3.4) 打包一个 Kivy 应用程序,以便在 Windows 机器上使用.我已经让它在我的机器上编译和工作,但是当将 exe 移动到另一个时,它无法给出错误:

                  I'm packaging a Kivy app using PyInstaller (3.4) for use on Windows machines. I've gotten it to compile and work on my machine but when moving the exe to another, it fails giving the error:

                  [WARNING] [Image       ] Unable to load image 
                  C:Users<OTHER_MACHINES_USER>AppDataLocalTemp_MEI38442kivy_installdataglsldefault.png>
                  [CRITICAL] [Window      ] Unable to find any valuable Window provider.
                  sdl2 - Exception: SDL2: Unable to load image
                  

                  当整个东西被复制时(如在 ./dist/client_iface.exe 中),这在 dist 文件夹中起作用,所以我认为这是一个依赖问题我'一直无法解决,显然是使用 SDL2.

                  This works from the dist folder when the whole thing is copied across (as in ./dist/client_iface.exe) and so I figure its a dependency issue I've been unable to resolve, apparently with SDL2.

                  我相信这个问题与 几乎相同这个问题 但是这个问题已经存在两年了,至今还没有成功的解决方案.

                  I believe that this problem is almost identical to this problem however that question is two years old and as yet has no successful solution.

                  我遵循了许多指南(包括 这个 从上面的帖子链接)但没有成功.

                  I've followed a number of guides (including this one which is linked from the above post) but with no success.

                  规范文件,根据 Kivy 指南进行了调整, 如下:

                  The spec file, with adjustments as per the Kivy guide, is as follows:

                  # -*- mode: python -*-
                  
                  from kivy.deps import sdl2, glew
                  import os
                  
                  block_cipher = None
                  
                  a = Analysis(
                      ['client_iface.py'],
                      pathex=['D:\Users\<USER>\Documents\2_Projects\py_dice_roller\client'],
                      binaries=[('D:\Users\<USER>\Documents\2_Projects\DnD\py_dice_roller\client\SDL2.dll', '.')],
                      datas=[],
                      hiddenimports=[],
                      hookspath=[],
                      runtime_hooks=[],
                      excludes=[],
                      win_no_prefer_redirects=False,
                      win_private_assemblies=False,
                      cipher=block_cipher,
                      noarchive=False
                  )
                  a.datas += [
                      ('client_iface.kv', '.\client_iface.kv', 'DATA'), 
                      ('active.png', '.\images\active.png', 'DATA'),
                      ('back.png', '.\images\active.png', 'DATA'),
                      ('normal.png', '.\images\active.png', 'DATA'),
                      ('DroidSansMono.ttf', '.\fonts\DroidSansMono.ttf', 'DATA')
                  ]
                  pyz = PYZ(a.pure, a.zipped_data,
                               cipher=block_cipher
                  )
                  exe = EXE(
                      pyz,
                      a.scripts,
                      a.binaries,
                      a.zipfiles,
                      a.datas,
                      [],
                      name='client_iface',
                      debug=False,
                      bootloader_ignore_signals=False,
                      strip=False,
                      upx=True,
                      runtime_tmpdir=None,
                      console=True,
                      icon='.imagesicon_dWU_icon.ico',
                  )
                  coll = COLLECT(
                      exe, Tree(os.getcwd()),
                      a.binaries,
                      a.zipfiles,
                      a.datas,
                      *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
                      strip=False,
                      upx=True,
                      name='client_iface'
                  )
                  

                  按照上面的链接,我在脚本中包含了以下代码:

                  And following the above linked I have included the following code in the script:

                  
                  def resourcePath(path):
                      if hasattr(sys, '_MEIPASS'):
                          return os.path.join(sys._MEIPASS)
                  
                      return os.path.join(os.path.abspath(path))
                  
                  if __name__ == '__main__':
                      kivy.resources.resource_add_path(resourcePath('.'))
                      kivy.resources.resource_add_path(resourcePath('./images'))
                      main_app().run()
                  
                  

                  我使用的命令是:

                  python -m PyInstaller -F --onefile .client_iface.spec
                  

                  预期结果是生成的单个可执行文件可以在任何类似机器上运行而不会出错或不需要整个文件夹的附加文件.

                  The expected result would be that the single executable produced would run on any like-machine without error-ing or the need for the entire folder of additional files.

                  任何帮助将不胜感激.

                  推荐答案

                  .spec 文件的 COLLECT 部分表示 onedir将创建可执行文件.为了使 onefile 可执行,您需要删除 COLLECT 部分.此外,COLLECT 部分中列出的 sdl2 和 glew deps 可以作为 *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)] 代替出现在第一个关键字参数之前的默认 [],.

                  The COLLECT section of your .spec file indicates that a onedir executable will be created. In order to make a onefile executable, you will need to remove the COLLECT section. Also, the sdl2 and glew deps that are listed in the COLLECT section can be added to the EXE section as *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)] in place of the default [], that appears before the first keyword argument.

                  另外,请注意,如果您使用的是 .spec 文件,则 Pyinstaller 的大多数命令行选项都会被忽略.有关详细信息,请参阅 文档.不幸的是,Pyinstaller 文档在很多地方都相当模糊.

                  Also, note that most of the command line options of Pyinstaller are ignored if you are using a .spec file. Refer to the documentation for more details. Unfortunately, the Pyinstaller documentation is rather vague in many places.

                  这篇关于PyInstalled Kivy 应用程序无法在第二台机器上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 Kivy 中显示一个 numpy 数组 下一篇:在 python 端的 kivy 中分配 id

                  相关文章

                    <bdo id='g9KI1'></bdo><ul id='g9KI1'></ul>
                      <legend id='g9KI1'><style id='g9KI1'><dir id='g9KI1'><q id='g9KI1'></q></dir></style></legend>

                      <small id='g9KI1'></small><noframes id='g9KI1'>

                    1. <tfoot id='g9KI1'></tfoot>
                      <i id='g9KI1'><tr id='g9KI1'><dt id='g9KI1'><q id='g9KI1'><span id='g9KI1'><b id='g9KI1'><form id='g9KI1'><ins id='g9KI1'></ins><ul id='g9KI1'></ul><sub id='g9KI1'></sub></form><legend id='g9KI1'></legend><bdo id='g9KI1'><pre id='g9KI1'><center id='g9KI1'></center></pre></bdo></b><th id='g9KI1'></th></span></q></dt></tr></i><div id='g9KI1'><tfoot id='g9KI1'></tfoot><dl id='g9KI1'><fieldset id='g9KI1'></fieldset></dl></div>