# Encoding Error when running train-curve

**URL:** <https://support.prodi.gy/t/encoding-error-when-running-train-curve/4406>\
**Category:** Uncategorized\
**Tags:** nightly, training, done\
**Created:** [July 4, 2021, 10:27am UTC](https://support.prodi.gy/t/encoding-error-when-running-train-curve/4406 "2021-07-04T10:27:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![lnatprodigy](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@lnatprodigy](https://support.prodi.gy/u/lnatprodigy)\
**Post date:** [July 4, 2021, 10:27am UTC](https://support.prodi.gy/t/encoding-error-when-running-train-curve/4406/1 "2021-07-04T10:27:44Z")

</div>

Hi,

I was wanting to try the train-curve recipe but I get the followin error when I run it:

> Traceback (most recent call last):  
> File "C:\Users\x\AppData\Local\Programs\Python\Python37\Lib\runpy.py", line 193, in \_run\_module\_as\_main  
> " **main**", mod\_spec)  
> File "C:\Users\x\AppData\Local\Programs\Python\Python37\Lib\runpy.py", line 85, in _run\_code  
> exec(code, run\_globals)  
> File "C:\Users\x.virtualenvs\prodigy\_nightly\_v3-x0wIMKXr\lib\site-packages\prodigy\_main_.py", line 54, in   
> controller = recipe(_args, use\_plac=True)  
> File "cython\_src\prodigy\core.pyx", line 329, in prodigy.core.recipe.recipe\_decorator.recipe\_proxy  
> File "C:\Users\x.virtualenvs\prodigy\_nightly\_v3-x0wIMKXr\lib\site-packages\plac\_core.py", line 367, in call  
> cmd, result = parser.consume(arglist)  
> File "C:\Users\x.virtualenvs\prodigy\_nightly\_v3-x0wIMKXr\lib\site-packages\plac\_core.py", line 232, in consume  
> return cmd, self.func(_(args + varargs + extraopts), \*\*kwargs)  
> File "C:\Users\x.virtualenvs\prodigy\_nightly\_v3-x0wIMKXr\lib\site-packages\prodigy\recipes\train.py", line 331, in train\_curve  
> config, gpu\_id=gpu\_id, overrides=overrides, silent=True  
> File "C:\Users\x.virtualenvs\prodigy\_nightly\_v3-x0wIMKXr\lib\site-packages\prodigy\recipes\train.py", line 172, in \_train  
> spacy\_train(nlp, output\_path, use\_gpu=gpu\_id, stdout=stdout)  
> File "C:\Users\x.virtualenvs\prodigy\_nightly\_v3-x0wIMKXr\lib\site-packages\spacy\training\loop.py", line 91, in train  
> stdout.write(msg.info(f"Pipeline: {nlp.pipe\_names}") + "\n")  
> File "C:\Users\x.virtualenvs\prodigy\_nightly\_v3-x0wIMKXr\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 '\u2139' in position 0: character maps to

I'm mostly posting this to report this issue. Since I'm not getting this error anywhere else (training, eval, ... all run fine), with the exact same dataset, I think it might be a bug or at least something that is being handled more gracefuly in other places?

Since it contains proprietary data, I won't be able to provide the dataset.

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [July 5, 2021, 12:55am UTC](https://support.prodi.gy/t/encoding-error-when-running-train-curve/4406/2 "2021-07-05T00:55:53Z")

</div>

Hi! Thanks for the report. From looking at the traceback, it seems like the problem comes down to an encoding issue when printing the formatted logging messages to `stdout`, so it doesn't seem to be related to the data or anything like that. It's surprising, though, that it only happens in the `train-curve` and not anywhere else (because `train-curve` really just calls into `train` under the hood) 🤔

What operating system and terminal are you using? And does setting the environment variable `WASABI_LOG_FRIENLDLY=1` help (which will disable any pretty-printing, icons and colours in the terminal outut)?

---

<div class="post-metadata">

**Author:** ![lnatprodigy](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@lnatprodigy](https://support.prodi.gy/u/lnatprodigy)\
**Post date:** [July 5, 2021, 4:48am UTC](https://support.prodi.gy/t/encoding-error-when-running-train-curve/4406/3 "2021-07-05T04:48:26Z")

</div>

> [@ines](#):
>
> What operating system and terminal are you using? And does setting the environment variable `WASABI_LOG_FRIENLDLY=1` help (which will disable any pretty-printing, icons and colours in the terminal outut)?

I'm on Windows 10 and using Powershell. Setting $env:WASABI\_LOG\_FRIENDLY=1 doesn't seem to help.  
I also tried it in the "normal" windows cmdline but I get the same result.

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [July 5, 2021, 5:42am UTC](https://support.prodi.gy/t/encoding-error-when-running-train-curve/4406/4 "2021-07-05T05:42:58Z")

</div>

Thanks for the update! I wonder if this is related to this line we use in the `train-curve` workflow to write the output to `devnull` so the detailed logs aren't showing up for every run:

```python
stdout = sys.stdout if not silent else open(os.devnull, "w")

```

Maybe there's something about writing to `os.devnull` in Windows that's different and needs special handling 🤔

Could you check whether one of these (or both) fail for you with a similar error? If so, this is likely what's going on here.

```python
import os
from wasabi import msg

stdout = open(os.devnull, "w")

# Test 1: just write something
stdout.write("hello world")
# Test 2: write formatted output
stdout.write(msg.info("hello world"))

```

---

<div class="post-metadata">

**Author:** ![lnatprodigy](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@lnatprodigy](https://support.prodi.gy/u/lnatprodigy)\
**Post date:** [July 5, 2021, 5:47am UTC](https://support.prodi.gy/t/encoding-error-when-running-train-curve/4406/5 "2021-07-05T05:47:32Z")

</div>

First one works (prints 11), second one I can't run because I don't have msg. Is that a package I need to install?

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [July 5, 2021, 5:49am UTC](https://support.prodi.gy/t/encoding-error-when-running-train-curve/4406/6 "2021-07-05T05:49:13Z")

</div>

Ah, that was supposed to be `wasabi.msg`, sorry! I'll edit my comment above.

---

<div class="post-metadata">

**Author:** ![lnatprodigy](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@lnatprodigy](https://support.prodi.gy/u/lnatprodigy)\
**Post date:** [July 5, 2021, 5:55am UTC](https://support.prodi.gy/t/encoding-error-when-running-train-curve/4406/7 "2021-07-05T05:55:35Z")

</div>

Since wasabi.msg.info seems to return None, I can only run the line without stdout.write, which works and prints "? hello world"

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [July 5, 2021, 6:05am UTC](https://support.prodi.gy/t/encoding-error-when-running-train-curve/4406/8 "2021-07-05T06:05:58Z")

</div>

Sorry, should have written this more carefuly. This is the correct test:

```python
import os
from wasabi import Printer

stdout = open(os.devnull, "w")

msg = Printer(no_print=True)
stdout.write(msg.info("hello world"))

```

---

<div class="post-metadata">

**Author:** ![lnatprodigy](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@lnatprodigy](https://support.prodi.gy/u/lnatprodigy)\
**Post date:** [July 5, 2021, 6:15am UTC](https://support.prodi.gy/t/encoding-error-when-running-train-curve/4406/9 "2021-07-05T06:15:51Z")

</div>

Yep, that recreated the error 🙂

changing stdout to

```python
stdout = open(os.devnull, "w", encoding="utf-8")

```

appears to resolve the issue for me.

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [July 5, 2021, 7:09am UTC](https://support.prodi.gy/t/encoding-error-when-running-train-curve/4406/10 "2021-07-05T07:09:08Z")

</div>

Ahh of course, that makes a lot of sense! Thanks for helping with debugging. Just fixed this for the next nightly release 👍

**Edit:** Fixed in v1.11.0a10: [✨ Prodigy nightly: spaCy v3 support, UI for overlapping spans & more - #85 by ines](https://support.prodi.gy/t/prodigy-nightly-spacy-v3-support-ui-for-overlapping-spans-more/3861/85)

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [July 6, 2021, 12:25am UTC](https://support.prodi.gy/t/encoding-error-when-running-train-curve/4406/11 "2021-07-06T00:25:44Z")

</div>

Split this topic on July 6, 2021, 12:25am UTC

A post was split to a new topic: [Misaligned entities only in train-curve](https://support.prodi.gy/t/misaligned-entities-only-in-train-curve/4412)
