Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 37: ordinal not in range(128) #386

Open
vanderlei52 opened this issue Jun 21, 2018 · 4 comments

Comments

@vanderlei52
Copy link

Ubuntu: 18.04 LT
Kivy: 1.11.0.dev0
python: 2.7.15

Traceback (most recent call last):
File "main2.py", line 1705, in
PApp().run()
File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 826, in run
runTouchApp()
File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 502, in runTouchApp
EventLoop.window.mainloop()
File "/usr/lib/python2.7/dist-packages/kivy/core/window/window_sdl2.py", line 727, in mainloop
self._mainloop()
File "/usr/lib/python2.7/dist-packages/kivy/core/window/window_sdl2.py", line 460, in _mainloop
EventLoop.idle()
File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 343, in idle
Builder.sync()
File "/usr/lib/python2.7/dist-packages/kivy/lang/builder.py", line 711, in sync
call_fn(next_args[:-1], None, None)
File "/usr/lib/python2.7/dist-packages/kivy/lang/builder.py", line 76, in call_fn
setattr(element, key, e_value)
File "kivy/graphics/instructions.pyx", line 362, in kivy.graphics.instructions.VertexInstruction.source.set
File "kivy/graphics/context_instructions.pyx", line 384, in kivy.graphics.context_instructions.BindTexture.source.set
File "/usr/lib/python2.7/dist-packages/kivy/core/image/init.py", line 536, in init
self.filename = arg
File "/usr/lib/python2.7/dist-packages/kivy/core/image/init.py", line 732, in _set_filename
mipmap=self._mipmap, nocache=self._nocache)
File "/usr/lib/python2.7/dist-packages/kivy/core/image/init.py", line 435, in load
im = loader(filename, **kwargs)
File "/usr/lib/python2.7/dist-packages/kivy/core/image/init.py", line 201, in init
self._data = self.load(filename)
File "/usr/lib/python2.7/dist-packages/kivy/core/image/img_sdl2.py", line 38, in load
info = _img_sdl2.load_from_filename(filename)
File "kivy/core/image/_img_sdl2.pyx", line 118, in kivy.core.image._img_sdl2.load_from_filename
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 37: ordinal not in range(128)

Thanks.

@dolang
Copy link

dolang commented Jun 21, 2018

Looks like you have a 'Ã' or some other non-ASCII character in the file name of one of your images. Python 2 is not very good at dealing with those, I'm afraid.

Can you rename that file and try again? Alternatively, try using Python 3 instead.

@vanderlei52
Copy link
Author

Thank you for your prompt reply,

I've searched all over my .py and .kv files and also in the name of all the image files.
Unfortunately I did not find any ASCII characters.
I believe the problem started when I installed the latest version 1.11.0.
Anyway, I uninstalled version 1.11.0 and reinstalled version 1.9.1.
With 1.9.1 my program is working normally now.

Thank you again.

@dolang
Copy link

dolang commented Jun 21, 2018

Well, that's weird. But good that you found a way to make it work again, at least.

What I meant was that you have a character in one of your file names that is not ASCII. Python 2 is simply not that great at handling those. It could've been another character, too.

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 <-- this is the byte that made it crash.

Now it depends on what the original encoding was. Commonly, that's latin1 aka ISO-8859-1. You can go have a look there and seek C3 in the table (that's 195 in decimal). E.g:

But if it was UTF-8 to begin with — which is also very likely — then it would've been the start of a 2-byte letter in the Latin set.

If you have some spare time, it would be interesting to see if you could try with Python 3 and/or find the offending file. v1.9.1 is quite old already.

@vanderlei52
Copy link
Author

Thank you for all your support.

Actually I do not believe the problem is in some image file or even in my .py source file.

Few days ago I was using Kivy 1.10 perfectly. Soon after an update to 1.11 the program started showing problems.

I have always controlled the problems with Docode in Python, since my language is Portuguese and we have many special characters (like french, spanish etc), but this time, even doing a check line by line (my program is not so big or complex) I did not find anything wrong.
In fact, if there was any special code, it would present the problem in any version of Python 2.7 or Kivy, but this was not the case. The problem only appeared in the last update of Kivy.

I think I'll wait a little before doing a new Kivy upgrade, since version 1.9 or 1.10 meets my needs. If it's a problem inside the Kivy library, maybe more people will report the same problem in the future. Anyway, for now I can work very well with the older versions of Kivy.

Thank you again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants