[Microbit-Python] importing modules using uflash

Ben Mustill-Rose ben at benmr.com
Sun Sep 11 04:48:59 EDT 2016


Hi,

If you're getting import errors it unfortunately means that the module
hasn't been included in the build of MicroPython for the micro:bit.

To expand on this a little, the way that uflash works is:

A vanilla copy of the runtime - E.G. with no scripts added is included
in the tool (from memory this starts at around line 314).
Unless otherwise specified via its parameters, when run, uflash will
create a hex representation of roundrobin.py and concatenate said
representation with the vanilla runtime.
The tool itself has no understanding of modules per say - all it does
is joins files together.

If you're interested in how it works I highly recommend having a look
at the code as it’s very readable.

Sorry to be the bearer of bad news - hopefully someone else may have
an idea as to how your problem can be solved.

Cheers,
Ben.


On 9/11/16, hot.toast via Microbit <microbit at python.org> wrote:
> I'm trying to test the micropython sheduler module "usched.py" on the
> microbit.
>
> The script I am using to test it "roundrobin.py" contains the line "from
> usched import Sched"
>
> If I flash the microbit using the command uflash roundrobin.py, I get an
> ImportError stating no module named 'usched'
>
> How do I get uflash to recognise that it needs to incorporate a module
> in the same path as the script?
>
>
>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>


More information about the Microbit mailing list