Skip to content

Decoding error when running on windows (in console) #4

Open
@e-ehrhardt

Description

@e-ehrhardt

from pysblgnt import morphgnt_rows
for row in morphgnt_rows(1): print(row)

...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\ProgramData\Anaconda3\envs\greek\lib\site-packages\pysblgnt\__init__.py", line 29, in morphgnt_rows
    for line in f:
  File "C:\ProgramData\Anaconda3\envs\greek\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 275: character maps to <undefined>

As far as I can tell, this is a Windows thing, where by default utf-8 is not used with open. When importing this as a module then, it's not possible to open the files correctly.
Reference: http://www.macfreek.nl/memory/Encoding_of_Python_stdout (EDIT: Ok maybe that's not the appropriate link since that talks about writing out for files rather than reading them in, but it's the same thing going on. Line 28 of __init.py with open(filename) as f: fails for me because utf-8 encoding isn't specified.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions