← index #15228Issue #18643
Related · medium · value 1.176
QUERY · ISSUE

Unable to print unicode characters when running repl with mpremote

openby XuanTongYaoopened 2024-06-08updated 2026-01-10
bugtoolsunicode

Port, board and/or hardware

RP2 Pico

MicroPython version

MicroPython v1.22.1 on 2024-01-05; Raspberry Pi Pico with RP2040

Reproduction

  1. Create a file called tt.py
  2. Write the following contents
print("你好")
  1. Run this command in the same directory:mpremote mount .
  2. import tt

Expected behaviour

Expected to print "你好".

Observed behaviour

PS D:\PROJECTS\Github\MicroPython-uFont> mpremote mount .
Local directory . is mounted at /remote
Connected to MicroPython at COM6
Use Ctrl-] or Ctrl-x to exit this shell
>
MicroPython v1.22.1 on 2024-01-05; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>> import tt
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\YHW\AppData\Local\Programs\Python\Python312\Scripts\mpremote.exe\__main__.py", line 7, in <module>
  File "C:\Users\YHW\AppData\Local\Programs\Python\Python312\Lib\site-packages\mpremote\main.py", line 536, in main
    do_repl(state, argparse_repl().parse_args([]))
  File "C:\Users\YHW\AppData\Local\Programs\Python\Python312\Lib\site-packages\mpremote\repl.py", line 89, in do_repl
    do_repl_main_loop(
  File "C:\Users\YHW\AppData\Local\Programs\Python\Python312\Lib\site-packages\mpremote\repl.py", line 54, in do_repl_main_loop  
    console_out_write(console_data_out)
  File "C:\Users\YHW\AppData\Local\Programs\Python\Python312\Lib\site-packages\mpremote\repl.py", line 83, in console_out_write  
    console.write(b)
  File "C:\Users\YHW\AppData\Local\Programs\Python\Python312\Lib\site-packages\mpremote\console.py", line 119, in write
    buf = buf.decode() if isinstance(buf, bytes) else buf
          ^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 0-1: unexpected end of data

Additional Information

Obviously this error occurs on the PC, so I guess there must be something wrong with the mpremote source code. The error is also triggered when printing other unicode characters, such as Japanese, emoji, etc.

As far as I know, many people use mpremote mount . to quickly demo their code, and I'd like to, but something went wrong.

Is there any way to avoid this problem?
I could convert unicode characters to hexadecimal and print them, but that's pointless.
Printing unicode characters works perfectly fine with tools like thonny.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

mpremote gives UnicodeError on ARDUINO_OPTA V26, V27, V28

openby tb4450opened 2026-01-05updated 2026-01-20
bugport-stm32

Port, board and/or hardware

ARDUINO_OPTA

MicroPython version

MicroPython v1.26.1 on 2025-09-11; Arduino OPTA with STM32H747

I do not have the WIFI version but the simplest without WIFI and RS485. Might this be the problem?

The same on V27 (latest) and V28 (preview).

py.exe -m mpremote connect COM9 fs tree
tree :
:/flash
mpremote: Error with transport:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
UnicodeError:

It's not possible to upload any file or use any filesystem function of mpremote.

mpremote repl works!

Using mpremote 1.27.0 on Windows with Python 3.14.2.

Thank you
Best greetings
Thomas

Reproduction

Connect OPTA and run mpremote.

py.exe -m mpremote connect COM9 fs tree
tree :
:/flash
mpremote: Error with transport:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
UnicodeError:

Expected behaviour

The command should give a similar output to the following;

py.exe -m mpremote connect COM10 fs tree
tree :
:/flash
├── BOOTEX.LOG
├── FOUND.000
│ ├── FILE0000.CHK
│ ├── FILE0001.CHK
│ ├── FILE0002.CHK
│ ├── FILE0003.CHK
│ └── FILE0004.CHK
├── README.txt
├── System Volume Information
│ ├── IndexerVolumeGuid
│ └── WPSettings.dat
├── _mqtt_test_pybd.txt
├── boot.py

Observed behaviour

mpremote ends with the error message "UnicodeError":

py.exe -m mpremote connect COM9 fs tree
tree :
:/flash
mpremote: Error with transport:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
UnicodeError:

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied