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.

UnicodeEncodeError: 'latin-1' codec can't encode characters when logging multiple runs

See original GitHub issue

I am trying to log multiple runs from a single script, as described in the API docs using wandb.init(reinit=True) and run.finish(). It gives a strange error that I do not understand, it seems to be output related, but it only appears at the 2nd iteration of the following loop. The first run is logged correctly to w&b and is also closed without an error.

for validation_partition in all_ids:
        run = wandb.init(reinit=True, name=f'Val{validation_partition}')
        logger.info('Initialized new w&b run.')
        #call main
        setattr(args, 'experiment_name', f'crossval_{test_partition}_{validation_partition}_{time.strftime("%Y-%m-%d-%H-%M",time.gmtime())}')
        best_mcc_det, best_mcc_cs = main_training_loop(args)
        result_list_det.append(best_mcc_det)
        result_list_cs.append(best_mcc_cs)
        logger.info(f'partition {validation_partition}: MCC Detection {best_mcc_det}, MCC CS {best_mcc_cs}')

        run.finish()
        logger.info(f'Finished partition {validation_partition}.')
wandb: Synced Test0_Val1: https://wandb.ai/fteufel/lm-sp-crossvalidation/runs/2i3alvte
20/09/30 00:14:47 - INFO - __main__ -   Finished partition 1.

wandb: wandb version 0.10.4 is available!  To upgrade, please run:
wandb:  $ pip install wandb --upgrade
wandb: Tracking run with wandb version 0.10.3
wandb: Syncing run Test0_Val2
Traceback (most recent call last):
  File "/zhome/1d/8/153438/experiments/py3-torch-env/lib/python3.6/site-packages/wandb/sdk/wandb_init.py", line 460, in init
    run = wi.init()
  File "/zhome/1d/8/153438/experiments/py3-torch-env/lib/python3.6/site-packages/wandb/sdk/wandb_init.py", line 398, in init
    run._on_start()
  File "/zhome/1d/8/153438/experiments/py3-torch-env/lib/python3.6/site-packages/wandb/sdk/wandb_run.py", line 1220, in _on_start
    self._display_run()
  File "/zhome/1d/8/153438/experiments/py3-torch-env/lib/python3.6/site-packages/wandb/sdk/wandb_run.py", line 1037, in _display_run
    click.style(project_url, underline=True, fg="blue"),
  File "/zhome/1d/8/153438/experiments/py3-torch-env/lib/python3.6/site-packages/wandb/errors/term.py", line 33, in termlog
    click.echo(line, file=sys.stderr, nl=newline)
  File "/zhome/1d/8/153438/experiments/py3-torch-env/lib/python3.6/site-packages/click/utils.py", line 272, in echo
    file.write(message)
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 7-8: ordinal not in range(256)
wandb: ERROR Abnormal program exit

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
vanpeltcommented, Oct 25, 2020

This is an issue with your terminal not supporting UTF8 characters in our output. We should detect this case, but in the meantime, setting the following in your terminal should fix this:

export LANG=C.UTF-8

You can add this to your ~/.profile or ~/.bash_rc if you’re on linux or mac. What OS are you guys using?

0reactions
sydhollcommented, Dec 27, 2021

In the past year we’ve majorly reworked the CLI and UI for Weights & Biases. We’re closing issues older than 6 months. Please comment to reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UnicodeEncodeError: 'latin-1' codec can't encode characters ...
I am trying to log multiple runs from a single script, as described in the API docs using wandb.init(reinit=True) and run.finish().
Read more >
UnicodeEncodeError: 'latin-1' codec can't encode character
I ran into this same issue when using the Python MySQLdb module. Since MySQL will let you store just about any binary data...
Read more >
codecs — Codec registry and base classes — Python 3.11.1 ...
Most standard codecs are text encodings, which encode text to bytes (and decode ... may differ): UnicodeEncodeError: 'latin-1' codec can't encode character ......
Read more >
Core metrics analysis error - UnicodeEncodeError, 'latin-1 ...
I validated the metadata file using Keemei and did not find errors or special symbols! In our sample ID column, we have the...
Read more >
Choose text encoding when you open and save files
To avoid problems with encoding and decoding text files, you can save files with Unicode encoding. Unicode accommodates most characters sets across all...
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