Importing a module

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
graemef
Posts: 5
Joined: Fri Jun 23, 2017 3:12 pm

Importing a module

Post by graemef » Thu Jul 27, 2017 5:32 am

Hi,

I have a question about using an external python project/module in micropython.

Specifically I tried as an experiment to load the mpmath project which is implemented in python.

It seems that it relies on modules such as operator.py distutils etc.

In the root directory (of mplab distro) is a file call setup.py which relies on distutils.setup which doesn't exist in micropython from what I can see.

So in this example operator.py and distutils.py are missing.

If these modules exist in the main python branch and are written in python, can I also expect them to work in micropython?

I am running on as STM32F746Discovery board for now and my scripts are on sdcard. So flash storage is not a problem. RAM is around 300KB.

So I guess my question is , assuming I can find the missing modules, would it be possible to use them?


Thanks Graeme

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

Re: Importing a module

Post by pythoncoder » Thu Jul 27, 2017 4:26 pm

A definitive, general, answer is impossible. Much code written for Python3 will run, but there are differences between MicroPython and CPython https://github.com/micropython/micropyt ... ifferences. Accommodating these may involve some work. Also RAM can be an issue for large libraries.
Peter Hinch
Index to my micropython libraries.

Post Reply