Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeEncodeError throw by export_bpe_vocab.py #1901

Closed
sheldonrobinson opened this issue Feb 20, 2025 · 0 comments · Fixed by #1902
Closed

UnicodeEncodeError throw by export_bpe_vocab.py #1901

sheldonrobinson opened this issue Feb 20, 2025 · 0 comments · Fixed by #1902

Comments

@sheldonrobinson
Copy link
Contributor

Problem

Encountered following error running export_bpe_vocab.py:

sherpa-onnx\scripts\export_bpe_vocab.py --bpe-model bpe.model
Traceback (most recent call last):
  File "sherpa-onnx\scripts\export_bpe_vocab.py", line 70, in <module>
    main()
  File "sherpa-onnx\scripts\export_bpe_vocab.py", line 65, in main
    vfile.write(f"{v}\t{sp.get_score(id)}\n")
  File "C:\Programs\Python\Python312\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u2581' in position 0: character maps to <undefined>

Solution

Add encoding utf-8 when opening the vfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant