Error while trying to install a micropython distribution package using upip

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
sara
Posts: 8
Joined: Thu Oct 03, 2019 12:26 pm

Error while trying to install a micropython distribution package using upip

Post by sara » Thu Oct 03, 2019 12:46 pm

Hello,
I am trying to use upip to install micropython-tinyrtc-i2c distribution package and it gave me the following error:

Code: Select all

Error installing 'micropython-tinyrtc-i2c': list index out of range, packages may be partially installed.
I'd like to know how to solve it!
Thanks in advance!

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Error while trying to install a micropython distribution package using upip

Post by pythoncoder » Fri Oct 04, 2019 7:25 am

upip installs libraries located on PyPi (https://pypi.org/) or in a special repository for the MicroPython library. The micropython-tinyrtc-i2c package doesn't seem to exist on PyPi. To install it you need to copy the program files from the GitHub archive to your device. To clone the GitHub library to your PC issue

Code: Select all

git clone https://github.com/mcauser/micropython-tinyrtc-i2c.git
From your PC you can then copy the Python files to your hardware using whatever IDE you are using or a command line tool like rshell.
Peter Hinch
Index to my micropython libraries.

sara
Posts: 8
Joined: Thu Oct 03, 2019 12:26 pm

Re: Error while trying to install a micropython distribution package using upip

Post by sara » Sun Oct 06, 2019 7:25 pm

Hum... I see, thanks!
So, I am gonna try to use mpy-cross to compile the .py file to .mpy file and then I'll use the ampy (https://github.com/scientifichackers/ampy) to send it to the board!
best regards,
Sara

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

Re: Error while trying to install a micropython distribution package using upip

Post by Roberthh » Sun Oct 06, 2019 7:45 pm

Unless you run into an memory error on running your code, you do not need to precompile it. Just copy the python files to your board.

sara
Posts: 8
Joined: Thu Oct 03, 2019 12:26 pm

Re: Error while trying to install a micropython distribution package using upip

Post by sara » Sun Oct 06, 2019 9:26 pm

ok, but, only for curiosity, answer me a doubt please:
Doesn't this procedure optimize the memory usage?
best regards,
Sara

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Error while trying to install a micropython distribution package using upip

Post by pythoncoder » Mon Oct 07, 2019 4:16 am

When you import a .py file the compiler runs on the target. This consumes RAM and may fail if the file is too big relative to the target's RAM. Cross-compiling removes the need for the compiler to run on the target and avoids this error.

The RAM used by the compiler should be reclaimed by the garbage collector once the compiler has run. So, if the import proceeds without error, the runtime benefits of cross-compiling are doubtful. There may be a reduction in RAM fragmentation.

Note that in both these cases the Python bytecode produced by the compiler exists in RAM. This can be avoided by using frozen bytecode where the bytecode is located in flash as part of a firmware build. This can save a lot of RAM at runtime.
Peter Hinch
Index to my micropython libraries.

Post Reply