[Solved] Error importing struct (Python)

Hey guys, I’m trying to code a Python script for use in MissionPlanner, but I’m getting a really weird problem when I try to open the script.

I get the error: "Error running script. No module named struct’.

This are my imports

import socket
import sys
import clr
import select
import struct
from thread import start_new_thread

clr.AddReference(“MissionPlanner”)
import MissionPlanner
clr.AddReference(“MissionPlanner.Utilities”) # Includes the Utilities class
from MissionPlanner.Utilities import Locationwp
clr.AddReference(“MAVLink”)
import MAVLink

I tried removing struct and the entire code works (except struct.pack/unpack etc), tried using struct on Python command line and it works, so it seems that the problem happens only when trying to use it with MissionPlanner. Any ideas?

Found the fix. Turns out that its because CPython implements “_struct” instead of “struct” to be compliant with some 2.5 version of something else.

So changing

import struct

to

import _struct

would work and then you can call for struct methods such as pack() and unpack() using

_struct.pack
_struct.unpack

More information here:
https://mail.python.org/pipermail/ironpython-users/2008-September/008342.html