How to Convert .py to .mpy for ESP32

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
AmirJ
Posts: 18
Joined: Tue Sep 03, 2019 9:48 am

How to Convert .py to .mpy for ESP32

Post by AmirJ » Sat Sep 07, 2019 5:37 am

hi
I need to compiled micropython file to run by ESP32. (To ensure manipulation and security.)
 

User avatar
jimmo
Posts: 553
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: How to Convert .py to .mpy for ESP32

Post by jimmo » Sat Sep 07, 2019 6:16 am

You need to use mpy-cross, which you can either build from source (make sure you checkout at the same version tag as your firmware), or the much easier option is to install using pip (see https://pypi.org/project/mpy-cross/ )

User avatar
Roberthh
Posts: 1572
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: How to Convert .py to .mpy for ESP32

Post by Roberthh » Sat Sep 07, 2019 6:27 am

Use mpy-cross on the PC to compile you .py files into .mpy files. I have a few compiled versions here: https://github.com/robert-hh/Shared-Stuff. Other people share that too. A search on the board will reveal it.

User avatar
AmirJ
Posts: 18
Joined: Tue Sep 03, 2019 9:48 am

Re: How to Convert .py to .mpy for ESP32

Post by AmirJ » Sat Sep 07, 2019 2:03 pm

Good
Thank you
It works.

User avatar
mattyt
Posts: 241
Joined: Mon Jan 23, 2017 6:39 am

Re: How to Convert .py to .mpy for ESP32

Post by mattyt » Sat Sep 07, 2019 2:32 pm

mpy-cross is also pip-installable (thanks AndrewL!):

https://pypi.org/project/mpy-cross/

Post Reply