How do I include the uctypes library module in a build?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
WhiteHare
Posts: 58
Joined: Thu Oct 04, 2018 4:00 am

How do I include the uctypes library module in a build?

Post by WhiteHare » Thu Oct 11, 2018 5:52 pm

Even though it's an official micropython library, uctypes doesn't seem to be a part of the default build:

Code: Select all


>>> help ('modules')
__main__          gc                os                ucollections
array             machine           random            uos
board             math              sys               ustruct
builtins          micropython       time              utime
Plus any modules on the filesystem
>>> import uctypes
Traceback (most recent call last):
  File "<stdin>", in <module>
ImportError: no module named 'uctypes'
>>>
How do I add the uctypes module in so that I can import and use it?

jickster
Posts: 511
Joined: Thu Sep 07, 2017 8:57 pm

Re: How do I include the uctypes library module in a build?

Post by jickster » Thu Oct 11, 2018 5:55 pm

WhiteHare wrote:
Thu Oct 11, 2018 5:52 pm
Even though it's an official micropython library, uctypes doesn't seem to be a part of the default build:

Code: Select all


>>> help ('modules')
__main__          gc                os                ucollections
array             machine           random            uos
board             math              sys               ustruct
builtins          micropython       time              utime
Plus any modules on the filesystem
>>> import uctypes
Traceback (most recent call last):
  File "<stdin>", in <module>
ImportError: no module named 'uctypes'
>>>
How do I add the uctypes module in so that I can import and use it?

In mpconfigport.h

Code: Select all

#define MICROPY_PY_UCTYPES          (1)

User avatar
WhiteHare
Posts: 58
Joined: Thu Oct 04, 2018 4:00 am

Re: How do I include the uctypes library module in a build?

Post by WhiteHare » Thu Oct 11, 2018 7:14 pm

Thanks! It worked. :D

Code: Select all

>>> help('modules')
__main__          machine           sys               ustruct
array             math              time              utime
board             micropython       ucollections
builtins          os                uctypes
gc                random            uos
Plus any modules on the filesystem
>>> import uctypes
>>>

Post Reply