UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
User avatar
Asahel
Newbie
Posts: 24
Joined: Fri Nov 14, 2014 10:38 am
Contact:

UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#1 Post by Asahel » Mon Nov 09, 2015 7:52 pm

Long story short, in the project I am trying my script.rpy is supposed to open an external .py file in the game directory. That .py file is encoded in utf8 and doesn't seem to have any irregular characters.

I've tried it in linux and windows7, and with different Ren'py sdk releases, and I am getting the same error. Here's the full traceback.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 20, in script
    $ import AIMLBot
  File "game/script.rpy", line 20, in <module>
    $ import AIMLBot
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4 in position 47219: invalid continuation byte

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 20, in script
    $ import AIMLBot
  File "/home/mint/Downloads/renpy-6.99.6-sdk/renpy/ast.py", line 797, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "/home/mint/Downloads/renpy-6.99.6-sdk/renpy/python.py", line 1448, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script.rpy", line 20, in <module>
    $ import AIMLBot
  File "/home/mint/Downloads/renpy-6.99.6-sdk/renpy/loader.py", line 677, in load_module
    exec code in mod.__dict__
  File "AIMLBot.py", line 1, in <module>
  File "/home/mint/Downloads/renpy-6.99.6-sdk/renpy/loader.py", line 677, in load_module
    exec code in mod.__dict__
  File "aiml/__init__.py", line 4, in <module>
  File "/home/mint/Downloads/renpy-6.99.6-sdk/renpy/loader.py", line 670, in load_module
    source = load(filename).read().decode("utf8")
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/encodings/utf_8.py", line 16, in decode
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4 in position 47219: invalid continuation byte

Linux-3.16.0-38-generic-x86_64-with-debian-jessie-sid
Ren'Py 6.99.6.739
ALICE 0.0
Help would be much appreciated!

User avatar
PyTom
Ren'Py Creator
Posts: 15423
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#2 Post by PyTom » Mon Nov 09, 2015 10:55 pm

If you get that error, the file is likely in latin-1 rather than UTF-8.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Asahel
Newbie
Posts: 24
Joined: Fri Nov 14, 2014 10:38 am
Contact:

Re: UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#3 Post by Asahel » Mon Nov 09, 2015 11:05 pm

But I saved and re-saved and re-re-saved in utf8 using Editra, jedit, gedit....I don't know what else to do!

User avatar
PyTom
Ren'Py Creator
Posts: 15423
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#4 Post by PyTom » Mon Nov 09, 2015 11:05 pm

Post the file, I'll look at it.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Asahel
Newbie
Posts: 24
Joined: Fri Nov 14, 2014 10:38 am
Contact:

Re: UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#5 Post by Asahel » Mon Nov 09, 2015 11:11 pm

It's the AIMLBot.py example offered by Karl_C here
http://lemmasoft.renai.us/forums/viewto ... =8&t=33398

It works for him, I don't know what I'm doing wrong :?

Code: Select all

import aiml
import os.path
import sys


class AimlBot:
   brainFileName = "standard.brn"
   kernel = aiml.Kernel()
   botName = "Eileen"

   def __init__(self):
      self.kernel.verbose(False)
      self.kernel.setBotPredicate("name", self.botName)

      if os.path.isfile(self.brainFileName):
          self.kernel.bootstrap(brainFile = self.brainFileName)
      else:
          self.kernel.bootstrap(learnFiles = "std-startup.xml", commands = "load aiml b")
          self.kernel.saveBrain(self.brainFileName)

   # runs bot on input and returns answer
   def run(self, inputString):
      answer =  self.kernel.respond(inputString) # second argument is string
      #self.kernel.saveBrain(self.brainFileName)
      return answer

User avatar
Karl_C
Veteran
Posts: 232
Joined: Sun Mar 31, 2013 6:18 am
Contact:

Re: UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#6 Post by Karl_C » Thu Nov 12, 2015 7:05 pm

Try the attached file.
Attachments
AIMLbot.py.zip
AIMLbot.py.zip
(495 Bytes) Downloaded 36 times

User avatar
Asahel
Newbie
Posts: 24
Joined: Fri Nov 14, 2014 10:38 am
Contact:

Re: UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#7 Post by Asahel » Fri Nov 13, 2015 8:12 am

Hello Karl_C. I've tried your file and getting the same error. In fact, I'm getting the same error with any python script I've attempted to import so far - Ive tried various scripts that work on their own.

User avatar
Karl_C
Veteran
Posts: 232
Joined: Sun Mar 31, 2013 6:18 am
Contact:

Re: UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#8 Post by Karl_C » Fri Nov 13, 2015 10:08 am

The same error with any python script you attempted to import so far? Strange...

As you're using a Linux machine: Can you do a

Code: Select all

locale charmap
in a console?

User avatar
Asahel
Newbie
Posts: 24
Joined: Fri Nov 14, 2014 10:38 am
Contact:

Re: UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#9 Post by Asahel » Fri Nov 13, 2015 8:18 pm

Code: Select all

mint@mint ~ $ locale charmap
UTF-8

Code: Select all

mint@mint ~ $ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=
mint@mint ~ $ 
:cry:

It was ANSI_X3.4-1968 and I've changed it to UTF-8. Still no joy.

User avatar
Karl_C
Veteran
Posts: 232
Joined: Sun Mar 31, 2013 6:18 am
Contact:

Re: UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#10 Post by Karl_C » Sat Nov 14, 2015 9:15 am

I remember that I had problems with this in the past, when I tried to copy code from the browser into my editor. Even after I saved the code afterwards with the correct "UTF-8" settings.

I "solved" the problem by typing the code directly in my editor. But your problem seems to be different, as even my working file doesn't work on your machine.

I'm sorry that I cannot help you, please try to search the board for "UTF-8" or "UnicodeDecodeError". Maybe you'll find a solution in the other postings.

PS: Just an idea: Can you try

Code: Select all

python -c "import sys; print(sys.stdout.encoding)"
?

User avatar
Asahel
Newbie
Posts: 24
Joined: Fri Nov 14, 2014 10:38 am
Contact:

Re: UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#11 Post by Asahel » Sun Nov 15, 2015 1:44 am

Code: Select all

mint@mint ~ $ python -c "import sys; print(sys.stdout.encoding)"
UTF-8
I've tried it today on a different linux machine and got the same error and I'm planning to test it on yet another windows computer tomorrow. This is really baffling.
I'm sorry that I cannot help you, please try to search the board for "UTF-8" or "UnicodeDecodeError". Maybe you'll find a solution in the other postings.
I might not get to the bottom of this but I appreciate your trying to help. Thank you.

User avatar
Karl_C
Veteran
Posts: 232
Joined: Sun Mar 31, 2013 6:18 am
Contact:

Re: UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#12 Post by Karl_C » Sun Nov 15, 2015 7:34 am

One last question / idea:

Are you using a renpy version from Linux Mint installed by the aptitude package manager?

Or are you using the lastest version from renpy's website?

User avatar
Asahel
Newbie
Posts: 24
Joined: Fri Nov 14, 2014 10:38 am
Contact:

Re: UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#13 Post by Asahel » Sun Nov 15, 2015 11:08 am

Karl_C wrote:Are you using a renpy version from Linux Mint installed by the aptitude package manager?

Or are you using the lastest version from renpy's website?
From the website.
It didn't occur to me I could find Ren'py in the package manager. Good point, I'll try that too!

User avatar
Asahel
Newbie
Posts: 24
Joined: Fri Nov 14, 2014 10:38 am
Contact:

Re: UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#14 Post by Asahel » Sun Nov 15, 2015 11:48 am

Same story. This is from the terminal:

Code: Select all

mint@mint ~ $ sudo su
mint mint # renpy

Full traceback:
  File "/usr/share/games/renpy/renpy/execution.py", line 288, in run
    node.execute()
  File "/usr/share/games/renpy/renpy/ast.py", line 718, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "/usr/share/games/renpy/renpy/python.py", line 1297, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script.rpy", line 20, in <module>
    $ import AIMLbot
  File "/usr/share/games/renpy/renpy/loader.py", line 543, in load_module
    exec code in mod.__dict__
  File "AIMLbot.py", line 1, in <module>
  File "/usr/share/games/renpy/renpy/loader.py", line 543, in load_module
    exec code in mod.__dict__
  File "aiml/__init__.py", line 4, in <module>
  File "/usr/share/games/renpy/renpy/loader.py", line 536, in load_module
    source = load(filename).read().decode("utf8")
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4 in position 47219: invalid continuation byte

While executing init code:
  File "game/script.rpy", line 20, in script
  File "game/script.rpy", line 20, in python
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4 in position 47219: invalid continuation byte

Full traceback:
  File "/usr/share/games/renpy/renpy/bootstrap.py", line 265, in bootstrap
    renpy.main.main()
  File "/usr/share/games/renpy/renpy/main.py", line 273, in main
    game.context().run(node)
  File "/usr/share/games/renpy/renpy/execution.py", line 288, in run
    node.execute()
  File "/usr/share/games/renpy/renpy/ast.py", line 718, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "/usr/share/games/renpy/renpy/python.py", line 1297, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script.rpy", line 20, in <module>
    $ import AIMLbot
  File "/usr/share/games/renpy/renpy/loader.py", line 543, in load_module
    exec code in mod.__dict__
  File "AIMLbot.py", line 1, in <module>
  File "/usr/share/games/renpy/renpy/loader.py", line 543, in load_module
    exec code in mod.__dict__
  File "aiml/__init__.py", line 4, in <module>
  File "/usr/share/games/renpy/renpy/loader.py", line 536, in load_module
    source = load(filename).read().decode("utf8")
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4 in position 47219: invalid continuation byte

While executing init code:
  File "game/script.rpy", line 20, in script
  File "game/script.rpy", line 20, in python
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4 in position 47219: invalid continuation byte



User avatar
Karl_C
Veteran
Posts: 232
Joined: Sun Mar 31, 2013 6:18 am
Contact:

Re: UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4

#15 Post by Karl_C » Sun Nov 15, 2015 1:33 pm

Ok, one last try.

Put the attached file into your game directory and unzip it. Do not try to re-save it.
Attachments
script.rpy.zip
script.rpy.zip
(565 Bytes) Downloaded 42 times

Post Reply

Who is online

Users browsing this forum: No registered users