Software
pymavlink
By ArduPilot, from github.com/ArduPilot/pymavlink (opens in a new tab)
- Drones and boats
- Library
- LGPL-3.0-or-later
A Python implementation of the MAVLink messaging protocol used by drones and robots, with a code generator for other languages and tools for analyzing flight logs.
Facts
- GitHub stars
- 740read on 6 Nov 2026
- Last update
- 5 Nov 2026Newest commit on master
- Maintenance
- Activea commit in the last 90 days
- Difficulty
- Intermediate
Checked on GitHub on 6 Nov 2026.
Licenses
- Code
- LGPL-3.0-or-later (opens in a new tab)
Read by Robotheca from COPYING (opens in a new tab) (LGPL-3.0-only) at commit 544d901 (opens in a new tab), on 6 Nov 2026. A person at Robotheca set it on 9 Nov 2026.
- Commercial use
- Yes
Copyleft: Modified source must be published.
Overview
What it does: Robotheca's summary
- Implements the MAVLink protocol in Python for communicating with vehicles.
- Includes a source code generator (mavgen.py) that creates MAVLink implementations for other programming languages.
- Provides tools for analyzing flight logs.
- Includes examples in the repository and supports Rust generation and MAVSpec/mavio interoperability.
- Installable from PyPI with pip; lxml is required, numpy and pytest are optional.
- Maps ArduPilot mode names to mode numbers, which can be extended via a custom_mode_map.json file.
Written by Robotheca from the project's README (opens in a new tab) at commit bd0a1b2, not by its creator.
The README
The creator's own README, copied as written: README.md by ArduPilot, at commit 544d901, under LGPL-3.0-or-later (opens in a new tab). The original on GitHub (opens in a new tab).
Read the README here
Image: Build Status (opens in a new tab) (opens in a new tab)
Pymavlink
This is a Python implementation of the MAVLink protocol. It includes a source code generator (generator/mavgen.py) to create MAVLink protocol implementations for other programming languages as well. Also contains tools for analyzing flight logs.
Documentation
Please see http://ardupilot.org/dev/docs/mavlink-commands.html (opens in a new tab) for mavlink command reference.
For realtime discussion please see the pymavlink Gitter channel (opens in a new tab)
Examples can be found in the repository (opens in a new tab) or in the ArduSub book (opens in a new tab)
Rust generation and MAVSpec/mavio interoperability are documented in generator/Rust/README.md (opens in a new tab).
Installation
Pymavlink supports Python 3. Python 2 support has been removed.
The following instructions assume you are using a Debian-based (like Ubuntu) installation.
Dependencies
Pymavlink has several dependencies :
- [lxml](http://lxml.de/installation.html) : for checking and parsing xml file
Optional :
- numpy : for FFT
- pytest : for tests
On Linux
lxml has some additional dependencies that can be installed with your package manager (here with apt):
sudo apt install libxml2-dev libxslt-dev
Optional for FFT scripts and tests:
sudo apt install python3-numpy python3-pytest
Analogously you can install the required dependencies for pymavlink:
sudo apt install python3-lxml
Alternatively, in the unlikely event that your distribution (other than Debian and its derivatives like Ubuntu) does not feature that package, you may decide to use pip and install the missing dependency from its source tree:
sudo apt install python3-pip
sudo python3 -m pip install --upgrade lxml
Yet another alternative is to use brew, in perfect analogy to how it is described for the macOS.
On macOS
lxml's native dependencies (libxml2 and libxslt) can be installed with Homebrew (opens in a new tab) :
brew install libxml2 libxslt
Install the Python dependencies with pip so they land in the same Python environment as pymavlink (Homebrew's numpy/pytest install into Homebrew's own Python interpreter, which is typically not the one running pymavlink) :
python3 -m pip install --upgrade lxml
Optional for FFT scripts and tests:
python3 -m pip install --upgrade numpy pytest
On Windows
Lxml can be installed with a Windows installer from here : https://pypi.org/project/lxml (opens in a new tab)
Installation
For users
It is recommended to install pymavlink from PyPI with pip, that way dependencies should be auto installed by pip.
sudo python3 -m pip install --upgrade pymavlink
Mavnative
Starting from September 2022, mavnative, a C extension for parsing mavlink, was deprecated and removed. Mavnative development was stalled for long time, it only supports MAVLink1 and doesn't get any fix on the protocol.
For developers
From the pymavlink directory, you can use :
(cd ..; git clone https://github.com/ArduPilot/mavlink.git)
MDEF=$PWD/../mavlink/message_definitions python3 -m pip install . -v
Since pip installation is executed from /tmp, it is necessary to point to the directory containing message definitions with MDEF. MDEF should not be set to any particular message version directory but the parent folder instead. If you have cloned from mavlink/mavlink then this is /mavlink/message_definitions . Using pip should auto install dependencies and allow you to keep them up-to-date.
Or:
python3 -m pip install .
Running the tests
From inside the pymavlink directory, fetch the message definitions alongside
the checkout and run the suite with pytest:
(cd ..; git clone https://github.com/ArduPilot/mavlink.git)
MDEF=$PWD/../mavlink/message_definitions PYTHONPATH=.. python3 -m pytest
MDEF points at the message definitions used to generate the dialects; if you
already have an ArduPilot checkout, point it at that mavlink/message_definitions
instead. PYTHONPATH=.. imports the local checkout rather than a pip-installed
copy.
Ardupilot Custom Modes
By default, pymavlink will map the Ardupilot mode names to mode numbers per the definitions in the ardupilotmega.xml (opens in a new tab) file. However, during development, it can be useful to add to or update the default mode mappings.
To do this:
- create a folder named
.pymavlinkin your home directory (i.e.$HOMEon Linux,$USERPROFILEon Windows); and - add a JSON file called
custom_mode_map.jsonto this new.pymavlinkfolder.
The JSON file is a dictionary that maps vehicle MAV_TYPE (opens in a new tab) value to a dictionary of mode numbers to mode names. An example that duplicates the existing mapping for MAV_TYPE_FIXED_WING (enum value of 1) vehicles is as follows:
{
"1": {
"0": "MANUAL",
"1": "CIRCLE",
"2": "STABILIZE",
"3": "TRAINING",
"4": "ACRO",
"5": "FBWA",
"6": "FBWB",
"7": "CRUISE",
"8": "AUTOTUNE",
"10": "AUTO",
"11": "RTL",
"12": "LOITER",
"13": "TAKEOFF",
"14": "AVOID_ADSB",
"15": "GUIDED",
"16": "INITIALISING",
"17": "QSTABILIZE",
"18": "QHOVER",
"19": "QLOITER",
"20": "QLAND",
"21": "QRTL",
"22": "QAUTOTUNE",
"23": "QACRO",
"24": "THERMAL"
"25": "LOITERALTQLAND",
"26": "AUTOLAND",
}
}
This custom_mode_map.json file can be used to:
- change the display name of an existing mode (e.g. change
"TAKEOFF"to"LAUNCH"); - add a new mode (e.g. add
"25": "NEW_MODE"); and - add a mapping for an unsupported vehicle type (e.g. add a mapping for
MAV_TYPE_AIRSHIP(enumvalue of7) vehicles).
Notes:
- Whilst the
MAV_TYPEand mode numbers are integers, they need to be defined asstrings in the JSON file, as raw integers can't be used as dictionary keys in JSON. - This feature updates the default definitions. You can use it to change the name-to-number mapping for a mode, but you completely can't remove an existing mapping.
License
pymavlink is released under the GNU Lesser General Public License v3 or later.
The source code generated by generator/mavgen.py is available under the permissive MIT License.
Files and versions
- Repository on GitHubgithub.com/ArduPilot/pymavlink (opens in a new tab)
- The version Robotheca read544d901 (opens in a new tab)
- Latest releasev2.4.50 (24 Sept 2026)
Robotheca read the repository at two versions: the summary at bd0a1b2 and the facts and the README at 544d901 (read on 6 Nov 2026).
Robotheca never hosts the code: each link goes to the creator's own page.
Use it
How to install it, in the creator's words: The project's README (opens in a new tab)
Robotheca doesn't review code. Read it before running it.
Robotheca lists software as a reference: nothing is hosted or run here, and every fact links to where it was read.