python 2.7 - attempted relative import in non-package error in mavlink

I've already looked through the forums, but I haven't found an answer that is mavlink specific.

I am currently writing script in python, and I want to use a python module of mavlink. The documentation for mavlink tells me to run from my mavlink folder. When I run this script, a gui appears asking for my xml files, a specified output directory, and what language I want my headers in. works when I choose to make headers for C, but it gives me the error: "attempted relative import in non-package" when I try to choose python. my xml files is located at:


and I have my python module output directory as:


below is a screenshot of my error.


can anyone tell me what I'm doing wrong?

1 Answer

  1. Leo- Reply


    This is quite an old question but i have just encountered with this problem. Solution that i have applied is: in replace following lines

    from mavgen import *


    from pymavlink.generator.mavgen import *

    I dont know the exact reason of the problem but from this thread i assume problem lies with python's interpretation of directories as packages.

    I have used python 2.7. Tried though to do with python 3.4 but didn't had chance there.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>