pyinstaller EXE文件无能为力

时间:2019-07-02 11:31:44

标签: python pyinstaller

我使用pyinstaller创建一个文件exe。它只能在少数几台计算机上工作。我不知道为什么。从命令窗口运行此文件时没有错误。我可以看到一秒钟的窗口,它消失了。以下是我的spec文件。没有安装防病毒软件。 Windows防火墙也被关闭。

SPEC

from kivy.deps import sdl2, glew
block_cipher = None
a = Analysis(['main.py'],
             pathex=['C:\\Users\\Patryk\\GUI\\EXE'],
             binaries=None,
             datas=None,
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)

exe = EXE(pyz,Tree('C:\\Users\\PycharmProjects\\GUI\\EXE'),
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
          name='Bajot2',
          debug=False,
          strip=False,
          upx=True,
          console=False, 
          runtime_tmpdir=None,
          icon='main_logo.ico' )

我设法看到了错误。那使我更接近解决它。

错误

[INFO   ] [Logger      ] Record log in C:\Users\Dell\.kivy\logs\kivy_19-07-02_7.
txt
[INFO   ] [Kivy        ] v1.10.1
[INFO   ] [Python      ] v3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1
900 64 bit (AMD64)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil
, img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] GLEW initialization succeeded
[INFO   ] [GL          ] Backend used <glew>
[INFO   ] [GL          ] OpenGL version <b'4.2.0 - Build 10.18.10.3262'>
[INFO   ] [GL          ] OpenGL vendor <b'Intel'>
[INFO   ] [GL          ] OpenGL renderer <b'Intel(R) HD Graphics 4600'>
[INFO   ] [GL          ] OpenGL parsed version: 4, 2
[INFO   ] [GL          ] Shading version <b'4.20 - Build 10.18.10.3262'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <16>
[WARNING] [Image       ] Unable to load image <C:\Users\Dell\AppData\Local\Temp\
_MEI40162\kivy_install\data\glsl\default.png>
[CRITICAL] [Window      ] Unable to find any valuable Window provider.
sdl2 - Exception: SDL2: Unable to load image
  File "site-packages\kivy\core\__init__.py", line 67, in core_select_lib
  File "site-packages\kivy\core\window\window_sdl2.py", line 140, in __init__
  File "site-packages\kivy\core\window\__init__.py", line 968, in __init__
  File "site-packages\kivy\core\window\window_sdl2.py", line 294, in create_wind
ow
  File "site-packages\kivy\core\window\__init__.py", line 1216, in create_window


  File "kivy\graphics\instructions.pyx", line 759, in kivy.graphics.instructions
.RenderContext.__init__
  File "site-packages\kivy\core\image\__init__.py", line 536, in __init__
  File "site-packages\kivy\core\image\__init__.py", line 732, in _set_filename
  File "site-packages\kivy\core\image\__init__.py", line 435, in load
  File "site-packages\kivy\core\image\__init__.py", line 201, in __init__
  File "site-packages\kivy\core\image\img_sdl2.py", line 41, in load
[CRITICAL] [App         ] Unable to get a Window, abort

4 个答案:

答案 0 :(得分:0)

可能是由于安装了不同的版本和软件包。尝试使用Python 3.6创建和环境,在其中安装Pyinstaller,它应该可以工作。

答案 1 :(得分:0)

从命令行启动可执行文件,打开一个cmd窗口并导航到您的exe,然后键入该exe的名称。

发生的事情是它抛出一个错误并立即关闭,然后才能读取它。如果从命令行启动,则命令窗口将保持打开状态,您将能够读取错误

答案 2 :(得分:0)

我始终强烈建议使用Windows批处理文件进行配置和using pyinstaller。这基本上是一个扩展名为“ .bat”或“ .cmd”的文本文件。您只需对其进行编辑,然后双击即可调用。

WINDOWS批处理文件

@echo off

:: Do what you like...

pyinstaller --clean ^
--one-file ^
--name BLABLA_PROG ^
main.spec

PAUSE

评论

最后一条命令对于调试很重要,因为命令窗口将保持打开状态。

答案 3 :(得分:0)

重新安装intel图形卡驱动程序.exe可以正常运行。