[Python] UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 0: unexpected...

Discussão em 'Python' iniciado por Stack, Fevereiro 22, 2025.

  1. Stack

    Stack Membro Participativo

    I am using FastText.load_fasttext_format()to load fastText Official Japanese trained model (300 dim) in Google Colab.

    Here is my code.

    model_path = "/content/drive/MyDrive/IDR/rakuten/wikipedia_fastText/cc.ja.300.bin"
    model = FastText.load_fasttext_format(model_path)


    And here is the encoding error.

    ---------------------------------------------------------------------------

    UnicodeDecodeError Traceback (most recent call last)

    <ipython-input-7-61d7c85f09b2> in <module>()
    2
    3 model_path = "/content/drive/MyDrive/IDR/rakuten/wikipedia_fastText/cc.ja.300.bin"
    ----> 4 model = FastText.load_fasttext_format(model_path)

    2 frames

    /usr/local/lib/python3.7/dist-packages/gensim/models/fasttext.py in _load_dict(self, file_handle, encoding)
    818 word_bytes += char_byte
    819 char_byte = file_handle.read(1)
    --> 820 word = word_bytes.decode(encoding)
    821 count, _ = self.struct_unpack(file_handle, '@qb')
    822

    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 0: unexpected end of data

    Continue reading...

Compartilhe esta Página