SystemError:<内置方法=“”getsize =“”of =“”font =“”object =“”at =“”return =“”null =“”without =“”setting =“”an =“” error =“”

时间:2017-12-06 17:22:59

标签: python python-3.x kivy pyinstaller

=“”

我有一个kivy应用程序,我正在努力运行作为python文件运行正常,但当我使用PyInstaller使它成为.exe失败,将错误抛给标题。

我已经将程序减少到尽可能小的程度,同时仍然可以重现错误。

.py文件:

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import *
from kivy.vector import Vector
from kivy.clock import Clock
from kivy.uix.stacklayout import StackLayout
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout


class scorecardProg(StackLayout):
    pass

class scorecard(App):
    def build(self):
        print("build")
        Prog = scorecardProg()
        return Prog

try:
    scorecard().run()
except Exception as err:
    print(err)
    input()

.kv文件:

#:kivy 1.0.9

<scorecardProg>:
    orientation: 'lr-tb'
    size: self.size
    pos: self.pos
    left_bit: left_bit
    units_field: units_field

    BoxLayout:
        id: left_bit

orientation: 'vertical'
width: 200
size_hint: None, 1
spacing: 10
padding: 10,10,10,10
units_field: units_field
canvas:
    Color:
        rgba: 1,1,1,0.2
    Rectangle:
        size: self.size
        pos: self.pos
Label:
    size: self.width, 30
    size_hint: 1,None
    pos: self.pos
    text: 'UNITS SHIPPED:'
TextInput:
    id: units_field
    size: self.width, 30
    size_hint: 1,None
    pos: self.pos
Widget:
    size_hint: 1,1

和运行.exe时的跟踪:

[INFO   ] [Logger      ] Record log in C:\Users\900007572\.kivy\logs\kivy_17-12-06_107.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: pil(['text_sdl2'] ignored)
build
[INFO   ] [OSC         ] using <thread> for socket
[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.4.0 - Build 21.20.16.4627'>
[INFO   ] [GL          ] OpenGL vendor <b'Intel'>
[INFO   ] [GL          ] OpenGL renderer <b'Intel(R) HD Graphics 530'>
[INFO   ] [GL          ] OpenGL parsed version: 4, 4
[INFO   ] [GL          ] Shading version <b'4.40 - Build 21.20.16.4627'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <32>
[INFO   ] [Shader      ] fragment shader: <b"WARNING: 0:7: '' :  #version directive missing">
[INFO   ] [Shader      ] vertex shader: <b"WARNING: 0:7: '' :  #version directive missing">
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
Parser: File "C:\Users\900007572\AppData\Local\Programs\Python\Python36-32\dist\scorecardTEST\scorecard.kv", line 31:
...
     29:        TextInput:
     30:            id: units_field
>>   31:            size: self.width, 30
     32:            size_hint: 1,None
     33:            pos: self.pos
...
SystemError: <built-in method getsize of Font object at 0x09655E18> returned NULL without setting an error
  File "C:\Users\900007572\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\lang\builder.py", line 601, in _apply_rule
    setattr(widget_set, key, value)
  File "kivy\weakproxy.pyx", line 33, in kivy.weakproxy.WeakProxy.__setattr__ (kivy\weakproxy.c:1471)
  File "kivy\properties.pyx", line 478, in kivy.properties.Property.__set__ (kivy\properties.c:5572)
  File "kivy\properties.pyx", line 1350, in kivy.properties.ReferenceListProperty.set (kivy\properties.c:21379)
  File "kivy\properties.pyx", line 571, in kivy.properties.Property.dispatch (kivy\properties.c:7105)
  File "kivy\_event.pyx", line 1225, in kivy._event.EventObservers.dispatch (kivy\_event.c:14035)
  File "kivy\_event.pyx", line 1131, in kivy._event.EventObservers._dispatch (kivy\_event.c:13193)
  File "C:\Users\900007572\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\uix\textinput.py", line 2088, in on_size
    self._refresh_hint_text()
  File "C:\Users\900007572\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\uix\textinput.py", line 2456, in _refresh_hint_text
    _lines, self._hint_text_flags = self._split_smart(self.hint_text)
  File "C:\Users\900007572\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\uix\textinput.py", line 2214, in _split_smart
    w = text_width(word, _tab_width, _label_cached)
  File "C:\Users\900007572\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\uix\textinput.py", line 1746, in _get_text_width
    width = _label_cached.get_extents(text)[0]
  File "C:\Users\900007572\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\text\text_pil.py", line 37, in get_extents
    w, h = font.getsize(text)
  File "C:\Users\900007572\AppData\Local\Programs\Python\Python36-32\lib\site-packages\PIL\ImageFont.py", line 156, in getsize
    size, offset 
= self.font.getsize(text, direction, features)

0 个答案:

没有答案