Python Kivy打包到exe

问题描述 投票:2回答:1

我正在尝试为Windows打包kivy。我使用的是带有python 3.7.2的windows 10和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()


This is warn-hello.txt


        This file lists modules PyInstaller was not able to find. This does not
        necessarily mean this module is required for running you program. Python and
        Python 3rd-party packages include a lot of conditional or optional module. 
        For
        example the module 'ntpath' only exists on Windows, whereas the module
    'posixpath' only exists on Posix systems.

    Types if import:
    * top-level: imported at the top-level - look at these first
    * conditional: imported within an if-statement
    * delayed: imported from within a function
    * optional: imported within a try-except-statement

    IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for
               yourself tracking down the missing module. Thanks!

    missing module named 'win32com.gen_py' - imported by win32com (conditional, optional), C:\Users\acer\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\loader\rthooks    \pyi_rth_win32comgenpy.py (top-level)
    missing module named pyimod03_importers - imported by C:\Users\acer\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_pkgres.py (top-level)
    missing module named _uuid - imported by uuid (optional)
    missing module named __builtin__ - imported by PIL.Image (optional), pkg_resources._vendor.pyparsing (conditional)
    missing module named ordereddict - imported by pkg_resources._vendor.pyparsing (optional)
    missing module named 'com.sun' - imported by pkg_resources._vendor.appdirs (delayed, conditional, optional)
    missing module named com - imported by pkg_resources._vendor.appdirs (delayed)
    missing module named 'pkg_resources.extern.pyparsing' - imported by pkg_resources._vendor.packaging.markers (top-level), pkg_resources._vendor.packaging.requirements (top-level)
    missing module named StringIO - imported by pygments.util (conditional), pkg_resources._vendor.six (conditional)
    missing module named __main__ - imported by pkg_resources (delayed, optional)
    missing module named pkg_resources.extern.packaging - imported by pkg_resources.extern (top-level), pkg_resources (top-level)
    missing module named pkg_resources.extern.appdirs - imported by pkg_resources.extern (top-level), pkg_resources (top-level)
    missing module named 'pkg_resources.extern.six.moves' - imported by pkg_resources (top-level), pkg_resources._vendor.packaging.requirements (top-level)
    missing module named pkg_resources.extern.six - imported by pkg_resources.extern (top-level), pkg_resources (top-level), pkg_resources.py31compat (top-level)
    missing module named 'multiprocessing.forking' - imported by C:\Users\acer\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_multiprocessing.py (optional)
    missing module named multiprocessing.get_context - imported by multiprocessing (top-level), multiprocessing.pool (top-level), multiprocessing.managers (top-level), multiprocessing.sharedctypes (top-level)
    missing module named multiprocessing.TimeoutError - imported by multiprocessing (top-level), multiprocessing.pool (top-level)
    missing module named multiprocessing.BufferTooShort - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
    missing module named multiprocessing.AuthenticationError - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
    missing module named multiprocessing.set_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level)
    missing module named multiprocessing.get_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level)
    missing module named multiprocessing.Event - imported by multiprocessing (optional), kivy.clock (optional)
    missing module named resource - imported by posix (top-level), C:\Users\acer\Desktop\coding\main.py (top-level)
    missing module named posix - imported by os (conditional, optional), C:\Users\acer\Desktop\coding\main.py (top-level)
    missing module named _posixsubprocess - imported by subprocess (conditional), multiprocessing.util (delayed), C:\Users\acer\Desktop\coding\main.py (top-level)
    missing module named readline - imported by cmd (delayed, conditional, optional), code (delayed, conditional, optional), pdb (delayed, optional), C:\Users\acer\Desktop\coding\main.py (top-level)
    excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional), C:\Users\acer\Desktop\coding\main.py (top-level)
    missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), C:\Users\acer\Desktop\coding\main.py (top-level)
    missing module named _winreg - imported by platform (delayed, optional), pygame (conditional), pygame.sysfont (conditional), C:\Users\acer\Desktop\coding\main.py (top-level), pkg_resources._vendor.appdirs     (delayed, conditional), pygments.formatters.img (optional)
    missing module named _scproxy - imported by urllib.request (conditional)
    missing module named java - imported by platform (delayed), C:\Users\acer\Desktop\coding\main.py (top-level)
    missing module named 'java.lang' - imported by platform (delayed, optional), C:\Users\acer\Desktop\coding\main.py (top-level), xml.sax._exceptions (conditional)
    missing module named vms_lib - imported by platform (delayed, conditional, optional), C:\Users\acer\Desktop\coding\main.py (top-level)
    missing module named termios - imported by tty (top-level), getpass (optional), C:\Users\acer\Desktop\coding\main.py (top-level)
    missing module named urllib.FancyURLopener - imported by urllib (conditional, optional), pygments.lexers._sourcemod_builtins (conditional, optional)
    missing module named urllib.urlretrieve - imported by urllib (conditional, optional), pygments.lexers._php_builtins (conditional, optional)
    missing module named urllib.urlopen - imported by urllib (conditional, optional), pygments.lexers._lua_builtins (conditional, optional), pygments.lexers._postgres_builtins (conditional, optional)
    missing module named urllib.pathname2url - imported by urllib (conditional), kivy.core.video.video_gstplayer (conditional), kivy.core.audio.audio_gstplayer (conditional)
    missing module named grp - imported by shutil (optional), tarfile (optional), pathlib (delayed), C:\Users\acer\Desktop\coding\main.py (top-level)
    missing module named 'org.python' - imported by pickle (optional), C:\Users\acer\Desktop\coding\main.py (top-level), xml.sax (delayed, conditional)
    missing module named pwd - imported by posixpath (delayed, conditional), shutil (optional), tarfile (optional), http.server (delayed, optional), webbrowser (delayed), pathlib (delayed, conditional, optional), netrc    (delayed, conditional), getpass (delayed), C:\Users\acer\Desktop\coding\main.py (top-level), docutils.frontend (delayed, conditional, optional)
    missing module named org - imported by copy (optional), C:\Users\acer\Desktop\coding\main.py (top-level)
    missing module named ios - imported by kivy.metrics (delayed, conditional), kivy.core.window (delayed)
    missing module named android - imported by kivy.metrics (delayed, conditional), kivy.core.window (delayed, conditional), kivy.base (delayed, optional), kivy.input.providers.androidjoystick (optional),     kivy.core.clipboard.clipboard_android (top-level), kivy.support (delayed, optional), kivy.core.window.window_pygame (conditional, optional)
    missing module named jnius - imported by kivy.metrics (delayed, conditional), kivy.core.clipboard.clipboard_android (top-level), kivy.core.camera.camera_android (top-level)  
    missing module named Queue - imported by kivy.compat (optional), pygame.threads (conditional)
    missing module named ConfigParser - imported by kivy.config (optional)
    missing module named Leap - imported by kivy.input.providers.leapfinger (delayed)
    missing module named copy_reg - imported by cStringIO (top-level), pygame (conditional)
    missing module named 'pygame._view' - imported by pygame (delayed)   
    missing module named pygame.sdlmain_osx - imported by pygame (top-level), pygame.macosx (top-level)
    missing module named OpenGL - imported by pygame (delayed)
    missing module named numpy - imported by PIL.ImageFilter (optional), pygame._numpysurfarray (top-level), pygame._numpysndarray (top-level), pygame (delayed), kivy.core.camera.camera_picamera (top-    level), kivy.core.camera.camera_android (delayed)
    missing module named 'pygame.movie' - imported by pygame (optional)
    missing module named pygame.SRCALPHA - imported by pygame (top-level), pygame.ftfont (top-level)
    missing module named Py25Queue - imported by pygame.threads (conditional)
    missing module named cStringIO - imported by pygame.compat (conditional), pygments.util (conditional)
    missing module named fcntl - imported by kivy.input.providers.hidinput (conditional), kivy.input.providers.linuxwacom (conditional)
    missing module named oscpy - imported by kivy.input.providers.tuio (delayed, optional)
    missing module named olefile - imported by PIL.FpxImagePlugin (top-level), PIL.MicImagePlugin (top-level)
    missing module named Tkinter - imported by PIL.ImageTk (conditional)
    missing module named UserDict - imported by PIL.PdfParser (optional)
    missing module named 'PySide.QtCore' - imported by PIL.ImageQt (conditional, optional)
    missing module named 'PyQt4.QtCore' - imported by PIL.ImageQt (conditional, optional)
    missing module named 'PySide2.QtCore' - imported by PIL.ImageQt (conditional, optional) 
    missing module named PySide2 - imported by PIL.ImageQt (conditional, optional)    
    missing module named 'PyQt5.QtCore' - imported by PIL.ImageQt (conditional, optional)
    missing module named pathlib2 - imported by PIL.Image (optional)
    missing module named cffi - imported by PIL.Image (optional), PIL.PyAccess (top-level), PIL.ImageTk (delayed, conditional, optional)
    missing module named PIL._imagingagg - imported by PIL (delayed, conditional, optional), PIL.ImageDraw (delayed, conditional, optional)
    missing module named smb - imported by kivy.loader (delayed, conditional, optional)
    missing module named urllib2 - imported by kivy.loader (delayed, conditional)
    missing module named 'pyobjus.dylib_manager' - imported by kivy.core.audio.audio_avplayer (top-level), kivy.core.clipboard.clipboard_nspaste (optional)
    missing module named pyobjus - imported by kivy.core.audio.audio_avplayer (top-level), kivy.core.clipboard.clipboard_nspaste (optional)
    missing module named new - imported by kivy.weakmethod (conditional)
    missing module named 'ffpyplayer.tools' - imported by kivy.core.image.img_ffpyplayer (top-level), kivy.core.video.video_ffpyplayer (optional), kivy.core.audio.audio_ffpyplayer (optional)
    missing module named 'ffpyplayer.player' - imported by kivy.core.video.video_ffpyplayer (optional), kivy.core.audio.audio_ffpyplayer (optional)
    missing module named ffpyplayer - imported by kivy.core.image.img_ffpyplayer (top-level), kivy.core.video.video_ffpyplayer (optional), kivy.core.audio.audio_ffpyplayer (optional)
    missing module named dbus - imported by kivy.core.clipboard.clipboard_dbusklipper (optional)
    missing module named ffmpeg - imported by kivy.core.video.video_ffmpeg (optional)
    missing module named 'ffpyplayer.pic' - imported by kivy.core.image.img_ffpyplayer (top-level)
    missing module named pygments.formatters.BBCodeFormatter - imported by pygments.formatters (top-level), kivy.uix.codeinput (top-level)
    missing module named ctags - imported by pygments.formatters.html (optional)
    missing module named colorama - imported by pygments.cmdline (delayed, conditional, optional)
    missing module named kivy.lib.vidcore_lite.egl - imported by kivy.lib.vidcore_lite (top-level), kivy.core.window.window_egl_rpi (top-level)
    missing module named kivy.lib.vidcore_lite.bcm - imported by kivy.lib.vidcore_lite (top-level), kivy.core.window.window_egl_rpi (top-level)
    missing module named 'twisted.internet' - imported by kivy.support (delayed)
    missing module named gobject - imported by kivy.support (delayed, optional)
    missing module named gi - imported by kivy.support (delayed, optional), kivy.core.clipboard.clipboard_gtk3 (top-level)
    missing module named enchant - imported by kivy.core.spelling.spelling_enchant (top-level)
    missing module named 'gi.repository' - imported by kivy.core.clipboard.clipboard_gtk3 (top-level), kivy.core.camera.camera_gi (top-level)
    missing module named AppKit - imported by kivy.core.spelling.spelling_osxappkit (top-level)
    missing module named android_mixer - imported by kivy.core.audio.audio_pygame (conditional, optional)
    missing module named 'android.mixer' - imported by kivy.core.audio.audio_pygame (conditional, optional)
    missing module named cv2 - imported by kivy.core.camera.camera_opencv (optional), kivy.core.camera.camera_android (delayed)
    missing module named Image - imported by kivy.core.image.img_pil (optional), docutils.writers._html_base (optional), docutils.writers.odf_odt (optional), docutils.parsers.rst.directives.images (optional)
    missing module named 'opencv.highgui' - imported by kivy.core.camera.camera_opencv (optional)
    missing module named opencv - imported by kivy.core.camera.camera_opencv (optional)
    missing module named picamera - imported by kivy.core.camera.camera_picamera (top-level)
    missing module named roman - imported by docutils.writers.latex2e (optional), docutils.writers.manpage (optional)
    missing module named elementtree - imported by docutils.writers.odf_odt (optional)
    missing module named 'android.runnable' - imported by kivy.core.clipboard.clipboard_android (top-level)

谢谢你的帮助。

python-3.x kivy exe pyinstaller
1个回答
0
投票

将以下内容添加到您的规范中:

Snippets - spec

# -*- 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')

Output

环境

  • Windows 10 Home
  • Pinstaller vz.4
  • Potchon v.7.2

App running

© www.soinside.com 2019 - 2024. All rights reserved.