Micropython on Linux, problen with *.mpy

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
User avatar
Alex_III
Posts: 5
Joined: Thu Mar 25, 2021 9:05 pm

Micropython on Linux, problen with *.mpy

Post by Alex_III » Fri Mar 26, 2021 5:12 pm

Compiled on Ubuntu, it works.
I wanted to install a library uasyncio.

Code: Select all

alex@ub2:~/micropython$ ./python -m upip install micropython-uasyncio
Installing to: /home/alex/.micropython/lib/
Installing micropython-uasyncio 3.0 from https://micropython.org/pi/uasyncio/uasyncio-3.0.tar.gz

alex@ub2:~$ ls ~/.micropython/lib/uasyncio
core.mpy  __init__.mpy  stream.mpy  task.mpy
Run program
I get an error.

Code: Select all

Traceback (most recent call last):
  File "/home/alex/PycharmProjects/pythonProject/main.py", line 16, in <module>
ValueError: incompatible .mpy file

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: Micropython on Linux, problen with *.mpy

Post by scruss » Sat Mar 27, 2021 3:56 pm

Yes, I found that too. Looks like the upip mpy files haven't been regenerated.

I removed the ~/.micropython/lib/uasyncio folder, then copied uasyncio's source from the extmod tree:

Code: Select all

cp -r extmod/uasyncio ~/.micropython/lib
That seemed to allow the module to at least load:

Code: Select all

./micropython 
MicroPython v1.14-122-g9fef1c0bd on 2021-03-27; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import uasyncio
>>> dir(uasyncio)
['__class__', '__getattr__', '__name__', '__file__', '__path__', 'sleep', 'sleep_ms', 'sys', 'ticks_add', 'ticks_diff', 'core', '__version__', '_attrs', 'wait_for', 'funcs', 'gather', 'Event', 'event', 'Lock', 'ticks', 'select', 'TaskQueue', 'Task', 'task', 'CancelledError', 'TimeoutError', 'SingletonGenerator', 'IOQueue', 'create_task', 'run_until_complete', 'run', 'Loop', 'get_event_loop', 'current_task', 'new_event_loop']
>>> 

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Micropython on Linux, problen with *.mpy

Post by kevinkk525 » Sat Mar 27, 2021 4:09 pm

or build micropython-dev for the unix port which includes uasyncio. (And complain on github so uasyncio gets finally merged in the non-dev unix port...)
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

Post Reply