Skip to content Skip to sidebar Skip to footer

Non-ascii Character '\xe2' In File But No Encoding Declared

I wrote a script to extract signals from the MIT-BIH dataset using the wfdb python library. The script was working fine when I was running it on windows but I recently shifted to M

Solution 1:

Please add following line at the top of the code.

# -*- coding: utf-8 -*-

Also, avoid using non-ascii quotations.

Solution 2:

This error is caused due to copying and pasting code from web which causes stray byte floating. You can find it by running.

withopen('my_script.py', 'r') as ms:
    for i, line inenumerate(ms):
        if'\xe2'in line:
            print(i, repr(line))

And the line and its index value will be printed where there is '\xe2':

4, "\xe2        word=string.printable(random.randint[0,61]) # Gets the random word"

Note: You should replace my_script.py with your respective .py file.

Solution 3:

This was due to a scipy bug which has been fixed.

Post a Comment for "Non-ascii Character '\xe2' In File But No Encoding Declared"