我正在尝试包装窗户用的奇异果。我正在将Windows 10与python 3.7.2和kivy 1.10.1一起使用。参照此documentation,我已经成功完成了exe的构建,但是当我运行exe时,它显示了以下错误
Error loading Python DLL 'C:\Users\acer\Desktop\coding\build\hello\python37.dll'.
LoadLibrary: The specified module could not be found.
谢谢您的帮助:D
这是我从python -m PyInstaller --name hello main.py
获得的规格
hello.spec
# -*- mode: python -*-
block_cipher = None
a = Analysis(['main.py'],
pathex=['C:\\Users\\acer\\Desktop\\coding'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='hello',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='hello')
这是我的代码块
import kivy from kivy.app import App from kivy.uix.label import Label from kivy.uix.button import Button from kivy.uix.textinput import TextInput from kivy.uix.floatlayout import FloatLayout from kivy.uix.widget import Widget
import sys kivy.require('1.10.1') class Main(App): def build(self): self.UIlayout = FloatLayout(size=(300,300)) self.textarea = TextInput(font_size=18) self.savebtn = Button(text="save",size_hint=(.1,.1),pos_hint={"bottom":0}) self.exitbtn = Button(text="exit",size_hint=(.1,.1),pos_hint={"right":1}) self.exitbtn.on_press = lambda: sys.exit(0) self.savebtn.on_press = self.savefile self.UIlayout.add_widget(self.textarea) self.UIlayout.add_widget(self.savebtn) self.UIlayout.add_widget(self.exitbtn) return self.UIlayout def savefile(self): print(self.textarea.text) with open("filename.py",'w') as f: f.write(self.textarea.text) Main().run()
import sys kivy.require('1.10.1') class Main(App): def build(self): self.UIlayout = FloatLayout(size=(300,300)) self.textarea = TextInput(font_size=18) self.savebtn = Button(text="save",size_hint=(.1,.1),pos_hint={"bottom":0}) self.exitbtn = Button(text="exit",size_hint=(.1,.1),pos_hint={"right":1}) self.exitbtn.on_press = lambda: sys.exit(0) self.savebtn.on_press = self.savefile self.UIlayout.add_widget(self.textarea) self.UIlayout.add_widget(self.savebtn) self.UIlayout.add_widget(self.exitbtn) return self.UIlayout def savefile(self): print(self.textarea.text) with open("filename.py",'w') as f: f.write(self.textarea.text) Main().run()
感谢您的帮助。
答案 0 :(得分:0)
在您的规格中添加以下内容:
# -*- mode: python -*-
from kivy.deps import sdl2, glew
.
.
.
coll = COLLECT(exe, Tree('C:\\Users\\acer\\Desktop\\coding\\')
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
strip=False,
upx=True,
name='hello')