MPY tool – manage files on devices running MicroPython

It is an alternative to ampy

Target of this project is to make more clean code, faster, better verbose output…


pip3 install mpytool



$ mpytool --help

list files:

$ mpytool -p /dev/ttyACM0 ls
$ mpytool -p /dev/ttyACM0 ls lib

tree files:

$ mpytool -p /dev/ttyACM0 tree

upload file or whole directory:

$ mpytool -p /dev/ttyACM0 put
$ mpytool -vp /dev/ttyACM0 put app/lib
$ mpytool -vp /dev/ttyACM0 --exclude-dir build --exclude-dir dist put app/src light_control

view content of file or download:

$ mpytool -p /dev/ttyACM0 get
$ mpytool -p /dev/ttyACM0 get >>

make directory, erase dir or files:

$ mpytool -p /dev/ttyACM0 mkdir a/b/c/d xyz/abc
$ mpytool -p /dev/ttyACM0 delete a xyz

restart only, restart and follow output:

$ mpytool -p /dev/ttyACM0 restart
$ mpytool -p /dev/ttyACM0 restart follow

Examples using API from Python

>>> import mpytool
>>> conn = mpytool.ConnSerial(port='/dev/ttyACM0', baudrate=115200)
>>> mpy = mpytool.Mpy(conn)
[('ehome', None), ('', 215), ('', 2938), ('project.json', 6404)]
>>> mpy.mkdir('a/b/c')
[('a', None),
 ('ehome', None),
 ('', 215),
 ('', 2938),
 ('project.json', 6404)]
>>> mpy.get('')
b"import time\nimport net\n\nwlan = net.Wlan()\nwlan.refresh_network()\n\nwhile wlan.ifconfig()[0] == '':\n    time.sleep(.1)\n\nprint('IP: ' + wlan.ifconfig()[0])\n\nimport ehome.ehome\n\nehome.ehome.start('project.json')\n"
>>> mpy.delete('a/b')

Verbose and debug output

use -v or -vv to show verbose output (like currently processing file, ..)

  • normally print only errors (red)
  • -d print warnings (yellow)
  • -dd print info messages (purple)
  • -ddd print debug messages (blue)

for reporting bugs, please provide in to issue also -ddd messages


for test used: ESP32S2 over USB 2MB RAM and 2MB FLASH:
recursive put of 30 files in 4 folders, 70KB total:

  • mpytool: 12.3s
  • ampy: 79.3s


Working only with MicroPython boards, not with CircuitPython

  • python v3.6+
  • pyserial v3.0+

Running on:

  • Linux
  • MacOS
  • Windows


(c) 2022 by Pavel Revak


  • Basic support is free over GitHub issues.
  • Professional support is available over email: Pavel Revak.


View Github