question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[CLI] UnicodeEncodeError: 'ascii' codec can't encode character '\u2b50'

See original GitHub issue

Description Using wandb through a SLURM job, I get an UnicodeEncodeError on some nodes on which code is being executed (not all). I narrowed down the issue and the character that raises the error (not obvious from the original message) is the “white medium star”: \u2b50.

How to reproduce Minimal script allowing to reproduce error: test.py

#!/usr/bin/env python
import wandb
wandb.init(reinit=True)
wandb.init(reinit=True)

launched with (SLURM command):

srun --pty test.py

Environment

  • OS: Ubuntu 20.04
  • Environment: anaconda
  • Python 3.6.12
  • WandB version: wandb-0.10.15

Backtrace

wandb: ERROR Abnormal program exit
Traceback (most recent call last):
  File "/home/gva/wandb-client/wandb/sdk/wandb_init.py", line 689, in init
    run = wi.init()
  File "/home/gva/wandb-client/wandb/sdk/wandb_init.py", line 486, in init
    run._on_start()
  File "/home/gva/wandb-client/wandb/sdk/wandb_run.py", line 1431, in _on_start
    self._display_run()
  File "/home/gva/wandb-client/wandb/sdk/wandb_run.py", line 1230, in _display_run
    click.style(project_url, underline=True, fg="blue"),
  File "/home/gva/wandb-client/wandb/errors/term.py", line 41, in termlog
    silent=not _show_info,
  File "/home/gva/wandb-client/wandb/errors/term.py", line 94, in _log
    click.echo(line, file=sys.stderr, nl=newline)
  File "/home/gva/miniconda3/lib/python3.6/site-packages/click/utils.py", line 272, in echo
    file.write(message)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 20-21: ordinal not in range(128)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    wandb.init(reinit=True)
  File "/home/gva/wandb-client/wandb/sdk/wandb_init.py", line 726, in init
    six.raise_from(Exception("problem"), error_seen)
  File "<string>", line 3, in raise_from
Exception: problem
    self._display_run()
  File "/home/gva/wandb-client/wandb/sdk/wandb_run.py", line 1230, in _display_run
    click.style(project_url, underline=True, fg="blue"),
  File "/home/gva/wandb-client/wandb/errors/term.py", line 41, in termlog
    silent=not _show_info,
  File "/home/gva/wandb-client/wandb/errors/term.py", line 94, in _log
    click.echo(line, file=sys.stderr, nl=newline)
  File "/home/gva/miniconda3/lib/python3.6/site-packages/click/utils.py", line 272, in echo
    file.write(message)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
andimarafioticommented, Jan 28, 2021

I have the same problem, the solution proposed by Gabriel works for me. Thanks mate!

1reaction
gabriel-vanzandyckecommented, Jan 26, 2021

a quick fix is to change the following in the final block of _log defined in wandb/errors/term.py:

        try:
            click.echo(line, file=sys.stderr, nl=newline)
        except:
            click.echo(line.encode(), file=sys.stderr, nl=newline)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure CLI : UnicodeEncodeError: 'ascii' codec can't encode ...
I have installed azure-cli using pip2 on alpine. When using azure-cli, in "vm create" command, I am getting above error. az login #worked...
Read more >
'ascii' codec can't encode character...' when using a Python ...
How do I get around the Python error "UnicodeEncodeError: 'ascii' codec can't encode character..." when using a Python script on the command line?...
Read more >
'ascii' codec can't encode character '\u2716' in position 9 ...
The details of the failure are as follows: UnicodeEncodeError: 'ascii' codec can't encode character '\u2716' in position 9: ordinal not in range(128) File ......
Read more >
1766445 – UnicodeEncodeError: 'ascii' codec can't encode ...
Bug 1766445 - UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in ... managercli: use encode('utf-8') in strings, 2021-01-17 17:23:50 UTC ...
Read more >
charmap' codec can't encode character '\xa3' in position 151
UnicodeEncodeError : 'charmap' codec can't encode characters in position 6-9: ... 'ascii' codec can't decode byte 0xc5 in position 223: ordinal not in ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found