1

I'm trying to run my kivy app using autorun on my Raspberry Pi. After restarting my OS it will run but during execution I faced up with encoding problem on the next lines of code:

CommonData.deviceSettings.Measurement.Alchogol = {}
for s in alchogolSettings:
    key = s["Name"].encode('utf-8').strip()
    value = s["Value"].encode('utf-8').strip()
    CommonData.deviceSettings.Measurement.Alchogol.update({key: value}) 

The next error occured during execution

'ascii' codec can't encode characters in position 0-14: ordinal not in range(128)

In the top of my .py file I setup next instructions:

 #!/usr/bin/python
    # -*- coding: utf8 -*-

The most interesting in this situation that if I will run this program from usual terminal it launch successfully, but when I'm trying to launch it using autorun this problem occurs

Does anybody know why this problem occurs and how to avoid it?

Tequila
  • 726
  • 7
  • 23
  • Duplicate of: http://stackoverflow.com/questions/9942594/unicodeencodeerror-ascii-codec-cant-encode-character-u-xa0-in-position-20?rq=1 ? – Tom Myddeltyn May 13 '16 at 13:07
  • 1
    honestly, I reed these post's but I think it is not my case just because this program works fine when I launch it using ssh client and does not work when it launched from autorun – Tequila May 13 '16 at 13:13
  • You should consider changing your title to indicate that? That you are seeing a difference between terminal and autorun? – Tom Myddeltyn May 13 '16 at 13:17
  • 1
    That's weird. There should be no encoding with default code in shown code. Please show a complete stack trace with the exact line where the error occurs. – Serge Ballesta May 13 '16 at 14:13
  • 2
    I found the reason of this problem. In my case I run a python script which is launch terminal and start another python script. The last script print some cyrrilic text to the terminal. This is where the problem lies. After deleting this print instruction I avoided this error. And this print instruction was located one line after the code I showed in this post – Tequila May 13 '16 at 14:21
  • 1
    You should edit your question and put in the "Answered my own question" box. – Tom Myddeltyn May 13 '16 at 15:16

1 Answers1

0

I found the reason of this problem. In my case I run a python script which is launch terminal and start another python script. The last script print some cyrrilic text to the terminal. This is where the problem lies. After deleting this print instruction I avoided this error. And this print instruction was located one line after the code I showed in this post

Tequila
  • 726
  • 7
  • 23