首页 > 解决方案 > 为Windows制作一个可执行的kivy文件,pyinstaller有问题

问题描述

我的目录中有4个文件:

  1. kv文件
  2. py文件
  3. SQLite 数据库
  4. py我要导入文件的py(2)文件

当我使用pyinstaller --onefile main.py它时,它会创建一个.exe文件。当我在控制台中运行此文件时,它会打印出:(No such file in directory: 'struct.kv'我的 kv 文件)。

我想将它添加到规范文件中。我写from kivy.deps import sdl2, glew了两行:

exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],

以及数据中发生的所有事情:datas=[ ( '/src/struct.kv', '.' )]. 但是当我尝试时,pyinstaller main.spec我收到了这个警告:

502 WARNING: stderr:     exec(text, spec_namespace)
File "<string>", line 2, in <module>
504 WARNING: stderr:   File "<string>", line 2, in <module>
ImportError: cannot import name 'sdl2'
509 WARNING: stderr: ImportError: cannot import name 'sdl2'

为什么我不能导入?

标签: pythonpython-3.xkivypyinstallersdl-2

解决方案


推荐阅读