Page 1 of 1

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

Posted: Thu Oct 11, 2018 5:52 pm
by WhiteHare
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?

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

Posted: Thu Oct 11, 2018 5:55 pm
by jickster
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)

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

Posted: Thu Oct 11, 2018 7:14 pm
by WhiteHare
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
>>>