Я очень новичок в создании GUI и Kivy, я использую Python 3. Я попытался запустить основной код, который я нашел в Интернете, но, похоже, существует проблема с кодировкой, которую я не смог решить. Мой код выглядит так:
import kivy
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
return Label(text = "A")
if __name__ == "__main__":
MyApp().run()
Я получаю следующее сообщение об ошибке:
UnicodeEncodeError: кодек 'charmap' не может кодировать символ '\ u0131' в позиции 280: символ отображается наundefined
Полная трассировка:
UnicodeEncodeError Traceback (most recent call last)
<ipython-input-3-2a8b8f5ea334> in <module>
12
13
---> 14 MyApp().run()
C:\ProgramData\Anaconda3\lib\site-packages\kivy\app.py in run(self)
827 self.load_config()
828 self.load_kv(filename=self.kv_file)
--> 829 root = self.build()
830 if root:
831 self.root = root
<ipython-input-3-2a8b8f5ea334> in build(self)
9
10 def build(self):
---> 11 return Label(text='Hello world')
12
13
kivy\_event.pyx in kivy._event.EventDispatcher.__cinit__()
kivy\properties.pyx in kivy.properties.Property.link()
kivy\properties.pyx in kivy.properties.NumericProperty.init_storage()
kivy\properties.pyx in kivy.properties.Property.init_storage()
kivy\properties.pyx in kivy.properties.NumericProperty.convert()
kivy\properties.pyx in kivy.properties.NumericProperty.parse_str()
kivy\properties.pyx in kivy.properties.NumericProperty.parse_list()
kivy\properties.pyx in kivy.properties.dpi2px()
C:\ProgramData\Anaconda3\lib\site-packages\kivy\utils.py in __get__(self, inst, cls)
503 if inst is None:
504 return self
--> 505 retval = self.func(inst)
506 setattr(inst, self.func.__name__, retval)
507 return retval
C:\ProgramData\Anaconda3\lib\site-packages\kivy\metrics.py in dpi(self)
172 # for all other platforms..
173 from kivy.base import EventLoop
--> 174 EventLoop.ensure_window()
175 return EventLoop.window.dpi
176
C:\ProgramData\Anaconda3\lib\site-packages\kivy\base.py in ensure_window(self)
121 '''Ensure that we have a window.
122 '''
--> 123 import kivy.core.window # NOQA
124 if not self.window:
125 Logger.critical('App: Unable to get a Window, abort.')
C:\ProgramData\Anaconda3\lib\site-packages\kivy\core\window\__init__.py in <module>
2066 if platform == 'linux':
2067 window_impl += [('x11', 'window_x11', 'WindowX11')]
-> 2068 Window = core_select_lib('window', window_impl, True)
C:\ProgramData\Anaconda3\lib\site-packages\kivy\core\__init__.py in core_select_lib(category, llist, create_instance, base, basemodule)
101 'debug logging (e.g. add -d if running from the command line, or '
102 'change the log level in the config) and re-run your app to '
--> 103 'identify potential causes\n{1}'.format(category.capitalize(), err))
104
105
C:\ProgramData\Anaconda3\lib\logging\__init__.py in critical(self, msg, *args, **kwargs)
1428 """
1429 if self.isEnabledFor(CRITICAL):
-> 1430 self._log(CRITICAL, msg, args, **kwargs)
1431
1432 fatal = critical
C:\ProgramData\Anaconda3\lib\logging\__init__.py in _log(self, level, msg, args, exc_info, extra, stack_info)
1517 record = self.makeRecord(self.name, level, fn, lno, msg, args,
1518 exc_info, func, extra, sinfo)
-> 1519 self.handle(record)
1520
1521 def handle(self, record):
C:\ProgramData\Anaconda3\lib\logging\__init__.py in handle(self, record)
1527 """
1528 if (not self.disabled) and self.filter(record):
-> 1529 self.callHandlers(record)
1530
1531 def addHandler(self, hdlr):
C:\ProgramData\Anaconda3\lib\logging\__init__.py in callHandlers(self, record)
1589 found = found + 1
1590 if record.levelno >= hdlr.level:
-> 1591 hdlr.handle(record)
1592 if not c.propagate:
1593 c = None #break out
C:\ProgramData\Anaconda3\lib\logging\__init__.py in handle(self, record)
903 self.acquire()
904 try:
--> 905 self.emit(record)
906 finally:
907 self.release()
C:\ProgramData\Anaconda3\lib\site-packages\kivy\logger.py in emit(self, message)
245 self._write_message(_message)
246
--> 247 self._write_message(message)
248
249
C:\ProgramData\Anaconda3\lib\site-packages\kivy\logger.py in _write_message(self, record)
216 stream.write(fs % msg.encode("UTF-8"))
217 else:
--> 218 stream.write(fs % msg)
219 stream.flush()
220
C:\ProgramData\Anaconda3\lib\encodings\cp1252.py in encode(self, input, final)
17 class IncrementalEncoder(codecs.IncrementalEncoder):
18 def encode(self, input, final=False):
---> 19 return codecs.charmap_encode(input,self.errors,encoding_table)[0]
20
21 class IncrementalDecoder(codecs.IncrementalDecoder):
UnicodeEncodeError: 'charmap' codec can't encode character '\u0131' in position 280: character maps to <undefined>
```