Unable to print unicode characters when running repl with mpremote
Port, board and/or hardware
RP2 Pico
MicroPython version
MicroPython v1.22.1 on 2024-01-05; Raspberry Pi Pico with RP2040
Reproduction
- Create a file called tt.py
- Write the following contents
print("你好")
- Run this command in the same directory:
mpremote mount . 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
ESP32-S3 `mpremote` sends corrupted fs hook when mounting local directory
Port, board and/or hardware
ESP32-S3 N8R8
MicroPython version
MicroPython 6fee099ca-dirty on 2025-06-25; Generic ESP32S3 module with Octal-SPIRAM with ESP32S3
Compiled using
- IDF 5.4.1
- python 3.13.1
- gcc-15
- macOS Sequoia 15.5
mpremote is used directly from the micropython repository (but the results are same as with latest PyPI version)
Reproduction
- Have a local folder named
local - Run
mpremote mount local
Expected behaviour
Expected to mount local directory on the device and enter the REPL
Observed behaviour
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File ".../micropython/tools/mpremote/mpremote/__main__.py", line 6, in <module>
sys.exit(main.main())
~~~~~~~~~^^
File ".../micropython/tools/mpremote/mpremote/main.py", line 615, in main
handler_func(state, args)
~~~~~~~~~~~~^^^^^^^^^^^^^
File ".../micropython/tools/mpremote/mpremote/commands.py", line 521, in do_mount
state.transport.mount_local(path, unsafe_links=args.unsafe_links)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../micropython/tools/mpremote/mpremote/transport_serial.py", line 304, in mount_local
self.exec(fs_hook_code)
~~~~~~~~~^^^^^^^^^^^^^^
File ".../micropython/tools/mpremote/mpremote/transport_serial.py", line 293, in exec
raise TransportExecError(ret, ret_err.decode())
mpremote.transport.TransportExecError: Traceback (most recent call last):
File "<stdin>", line 11
SyntaxError: invalid syntax
Additional Information
After some digging I found a recent thread #17465 which helped to resolve the issue.
After changing the size of a data chunk sent at once over REPL, mounting works as expected:
for i in range(0, len(command_bytes), 32):
self.serial.write(
command_bytes[i : min(i + 32, len(command_bytes))]
)
time.sleep(0.01)
The mpremote mount command works with an earlier build I found on the internet (this one)
So I guess the real problem lies in some build flag.
Code of Conduct
Yes, I agree