Compiling in unix and no "struct" module available

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
cloudformdesign
Posts: 35
Joined: Wed Mar 11, 2015 7:48 pm

Compiling in unix and no "struct" module available

Post by cloudformdesign » Sat Jun 13, 2015 6:06 pm

I can't seem to get the struct module when compiling in the unix folder

Code: Select all

$ cd unix
$ make
$ ./micropython 
Micro Python v1.4.3-150-ga19ba5f on 2015-06-13; linux version
>>> import struct
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'struct'
Am I doing something wrong here?

cloudformdesign
Posts: 35
Joined: Wed Mar 11, 2015 7:48 pm

Re: Compiling in unix and no "struct" module available

Post by cloudformdesign » Sat Jun 13, 2015 6:24 pm

so it does work after the following:

Code: Select all

micropython-pip install micropython-struct
However I thought struct was supposed to be in the standard library.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Compiling in unix and no "struct" module available

Post by pfalcon » Sat Jun 13, 2015 6:29 pm

MicroPython doesn't come with "struct" builtin, only "ustruct", which provides subset of functionality. More complete "struct" is in micropython-lib indeed, but "micropython-pip" is deprecated, since about a week, it's:

Code: Select all

micropython -m upip install micropython-struct
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

Post Reply