PyInstaller Kivy ClockApp示例问题 [英] PyInstaller Kivy ClockApp Example Issue

查看:84
本文介绍了PyInstaller Kivy ClockApp示例问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

===编辑结束===

===Edit End===

哇!

感谢以下&的建议(8)编译时间重新编译后,我可以通过多种方式解决我的问题:

Thanks to the suggestions below & (8) hours of compiling & recompiling I was able to fix my issues doing a combination of things:

  1. 了解如何正确调用Pyinstaller钩子才能正确调出模块.

  1. Understanding how Pyinstaller hooks are required in order to call out the modules correctly.

确保所有输入文件&输出文件文件位置在同一驱动器上.在我公司,我们的系统环境变量默认情况下设置为映射的网络驱动器,我必须确保所有用户环境变量设置默认情况下都映射为"C:\",以便pyinstaller可以将其选中.这包括将我的cmd.exe设置为正确的驱动器&目标文件输出.

Ensuring that all input file & output file file locations exist on the same drive. At my company, our system environment variables are set to a mapped network drive by default, I had to ensure all user environment variable settings were mapped to 'C:\' by default such that pyinstaller would pick it up. This included setting my cmd.exe to the correct drive & destination file output.

确保在构建正确的.spec文件之后,所有必需文件(.JPG,.kv,.PNG)文件都位于/dist文件夹中

Ensuring all necessary files (.JPG, .kv, .PNG) files were in the /dist folder AFTER I built the correct .spec file

我能够在kivy网站上打包PongGame示例,并在下面提到的Book/Chapter 2中打包Paint_App示例.

I was able to package the PongGame example on the kivy website as well as the Paint_App example for the Book/Chapter 2 mentioned below.

再次感谢.

===最后编辑结束===

===LAST Edit End===

===再次编辑===

===EDIT Again===

根据下面的建议,我试图运行显示错误日志的程序.

According to suggestion below, I've attempted to run program showing the error log.

但是,从cmd.exe运行甚至都不会吐出错误日志.

However, running from cmd.exe doesn't even spit out the error log.

但是,.kivy保留所有错误日志.

However, .kivy keeps all the error logs.

[INFO              ] Logger: Record log in H:\.kivy\logs\kivy_16-08-30_29.txt
[INFO              ] Kivy: v1.9.1
[INFO              ] Python: v3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)]
[INFO              ] Factory: 179 symbols loaded
[INFO              ] Image: Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
[INFO              ] OSC: using <thread> for socket
[INFO              ] Window: Provider: sdl2
[INFO              ] GL: GLEW initialization succeeded
[INFO              ] GL: OpenGL version <b'4.2.0'>
[INFO              ] GL: OpenGL vendor <b'NVIDIA Corporation'>
[INFO              ] GL: OpenGL renderer <b'Quadro K3000M/PCIe/SSE2'>
[INFO              ] GL: OpenGL parsed version: 4, 2
[INFO              ] GL: Shading version <b'4.20 NVIDIA via Cg compiler'>
[INFO              ] GL: Texture max size <16384>
[INFO              ] GL: Texture max units <32>
[INFO              ] Window: auto add sdl2 input provider
[INFO              ] Window: virtual keyboard not allowed, single mode, not docked
[INFO              ] Base: Start application main loop
[INFO              ] Base: Leaving application in progress...
[WARNING           ] stderr: Traceback (most recent call last):
[WARNING           ] stderr:   File "kivy\properties.pyx", line 754, in kivy.properties.ObservableDict.__getattr__ (kivy\properties.c:11776)
[WARNING           ] stderr: KeyError: 'time'
[WARNING           ] stderr: 
[WARNING           ] stderr: During handling of the above exception, another exception occurred:
[WARNING           ] stderr: 
[WARNING           ] stderr: Traceback (most recent call last):
[WARNING           ] stderr:   File "mainClock.py", line 40, in <module>
[WARNING           ] stderr:   File "site-packages\kivy\app.py", line 828, in run
[WARNING           ] stderr:   File "site-packages\kivy\base.py", line 487, in runTouchApp
[WARNING           ] stderr:   File "site-packages\kivy\core\window\window_sdl2.py", line 619, in mainloop
[WARNING           ] stderr:   File "site-packages\kivy\core\window\window_sdl2.py", line 362, in _mainloop
[WARNING           ] stderr:   File "site-packages\kivy\base.py", line 327, in idle
[WARNING           ] stderr:   File "site-packages\kivy\clock.py", line 515, in tick
[WARNING           ] stderr:   File "site-packages\kivy\clock.py", line 647, in _process_events
[WARNING           ] stderr:   File "site-packages\kivy\clock.py", line 406, in tick
[WARNING           ] stderr:   File "mainClock.py", line 32, in update
[WARNING           ] stderr:   File "kivy\properties.pyx", line 757, in kivy.properties.ObservableDict.__getattr__ (kivy\properties.c:11882)
[WARNING           ] stderr: AttributeError: 'super' object has no attribute '__getattr__'

===再次编辑结束===

===EDIT AGAIN End===

在build文件夹中,我看到一个warnmainClock.txt,其中有很多行,表示我缺少模块.

Looking in the build folder, I see a warnmainClock.txt with a ridiculously LARGE number of lines saying I'm missing modules.

这是否意味着我没有正确链接到我的python文件夹库?

Does this mean I'm not linking to my python folder library correctly?

例如:

missing module named _collections.deque - imported by _collections, collections, threading, C:\Python34x86\Examples\kivy\mainClock.py
missing module named _thread.stack_size - imported by _thread, threading, C:\Python34x86\Examples\kivy\mainClock.py
missing module named _thread._local - imported by _thread, threading, C:\Python34x86\Examples\kivy\mainClock.py
missing module named threading.current_thread - imported by threading, _threading_local, C:\Python34x86\Examples\kivy\mainClock.py
missing module named threading.RLock - imported by threading, _threading_local, bz2, multiprocessing.dummy, C:\Python34x86\Examples\kivy\mainClock.py
missing module named sys.modules - imported by sys, dummy_threading, C:\Python34x86\Examples\kivy\mainClock.py
missing module named _dummy_threading - imported by dummy_threading, C:\Python34x86\Examples\kivy\mainClock.py
missing module named _dummy_threading.__all__ - imported by _dummy_threading, dummy_threading, C:\Python34x86\Examples\kivy\mainClock.py
missing module named dummy_threading.RLock - imported by dummy_threading, bz2, C:\Python34x86\Examples\kivy\mainClock.py
missing module named dummy_threading.local - imported by dummy_threading, numpy.distutils.misc_util, C:\Python34x86\Examples\kivy\mainClock.py
missing module named time.monotonic - imported by time, subprocess, threading, queue, C:\Python34x86\Examples\kivy\mainClock.py
missing module named time.time - imported by time, subprocess, threading, queue, kivy.uix.behaviors.button, kivy.uix.behaviors.compoundselection, kivy.effects.kinetic, kivy.uix.filechooser, kivy.input.motionevent, kivy.input.postproc.doubletap, kivy.input.postproc.tripletap, multiprocessing.managers, multiprocessing.synchronize, C:\Python34x86\Examples\kivy\mainClock.py
missing module named Queue - imported by kivy.compat, C:\Python34x86\Examples\kivy\mainClock.py
missing module named time.strftime - imported by time, kivy.logger, C:\Python34x86\Examples\kivy\mainClock.py
missing module named kivy.app.App - imported by kivy.app, kivy.uix.scrollview, kivy.uix.screenmanager, kivy.uix.filechooser, kivy.uix.textinput, kivy.uix.settings, kivy.lang, kivy.support, kivy.core.window.window_sdl2, kivy.uix.video, kivy.uix.carousel, kivy.uix.treeview, kivy.uix.colorpicker, kivy.uix.splitter, kivy.uix.slider, kivy.uix.codeinput, C:\Python34x86\Examples\kivy\mainClock.py

编辑结束

我目前正在从Mark Vasilkov撰写的"Kivy Blueprints"一书中学习Kivy.

I am currently learning Kivy from the book "Kivy Blueprints" by Mark Vasilkov.

我正在尝试将第1章中的ClockApp打包.该代码可从python命令行完美运行.但是,使用pyinstaller创建Windows程序包时遇到了问题.

I am attempting to package the ClockApp from chapter 1 as an exercise. The code works perfectly from python command line. However, I am running into an issue using pyinstaller to create a windows package.

源代码& .kv文件可在此处找到 https://github.com/mvasilkov/kb/tree/master/1_Clock

The source code & .kv file is found here https://github.com/mvasilkov/kb/tree/master/1_Clock

我已按照示例 https://kivy.org/docs/guide/Packaging-windows.html

我使用以下命令在命令提示符下创建了一个Windows程序包:

I created a windows package from the command prompt using:

C:\Python34x86\Scripts\pysintaller C:\Python34x86\Examples\kivy\mainClock.py --noconsole

然后我使用以下方式从规范文件中构建:

Then I build from the spec file using:

C:\Python34x86\Scripts\pyinstaller H:\mainClock.spec

这两个命令均按指定在我的H驱动器中创建/dist文件.

Both commands create the /dist file in my H drive as specified.

仅从\ mainClock.py构建后访问EXE文件时,出现错误:

When I access the EXE file after just building from the \mainClock.py, I get the error:

在构建.spec文件后运行EXE文件时,我得到以下信息:

When I run the EXE file after building the .spec file I get the following:

.spec文件如下所示:

The .spec file looks like this:

# -*- mode: python -*-

block_cipher = None


a = Analysis(['C:\\Python34x86\\Examples\\kivy\\mainClock.py'],
             pathex=['H:\\'],
             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,
          a.scripts,
          exclude_binaries=True,
          name='mainClock',
          debug=True,
          strip=False,
          upx=True,
          console=False )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='mainClock')

我认为问题并非源于此,有人可以指出我做错了什么吗?

I think the issue isn't stemming from the source, can someone please point out what am I doing incorrectly?

推荐答案

下面的代码可能对您有进一步的帮助吗?

May be the following code can help you further?

# -*- mode: python -*-

import os
from os.path import join

from kivy import kivy_data_dir
from kivy.deps import sdl2, glew
from kivy.tools.packaging import pyinstaller_hooks as hooks

block_cipher = None
kivy_deps_all = hooks.get_deps_all()
kivy_factory_modules = hooks.get_factory_modules()

datas = []

# list of modules to exclude from analysis
excludes = ['Tkinter', '_tkinter', 'twisted', 'pygments']

# list of hiddenimports
hiddenimports = kivy_deps_all['hiddenimports'] + kivy_factory_modules

# binary data
sdl2_bin_tocs = [Tree(p) for p in sdl2.dep_bins]
glew_bin_tocs = [Tree(p) for p in glew.dep_bins]
bin_tocs = sdl2_bin_tocs + glew_bin_tocs

# assets
kivy_assets_toc = Tree(kivy_data_dir, prefix=join('kivy_install', 'data'))
source_assets_toc = []
assets_toc = [kivy_assets_toc, source_assets_toc]

tocs = bin_tocs + assets_toc


a = Analysis(['C:\\Python34x86\\Examples\\kivy\\mainClock.py'],
             pathex=['H:\\'],
             binaries=None,
             datas=datas,
             hiddenimports=hiddenimports,
             hookspath=[],
             runtime_hooks=[],
             excludes=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,
          a.scripts,
          name='mainClock',
          exclude_binaries=True,
          debug=False,
          strip=False,
          upx=True,
          console=False)

coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               *tocs,
               strip=False,
               upx=True,
               name='mainClock')

这篇关于PyInstaller Kivy ClockApp示例问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆