[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

import MissionPlanner
clr.AddReference(“MissionPlanner.Utilities”) # Includes the Utilities class
from MissionPlanner.Utilities import Locationwp
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


import _struct

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


More information here: