# MAVSDK-Python
[](https://github.com/mavlink/MAVSDK-Python/actions/workflows/main.yml?query=branch%3Amain)
This is the Python wrapper for MAVSDK.
The Python wrapper is based on a gRPC client communicating with the gRPC server written in C++. To use the Python wrapper the gRPC server called "backend" needs to be running on the same system. The wrapper is essentially auto-generated from the message definitions ([proto files](https://github.com/mavlink/MAVSDK-Proto)).
## Important Notes
- Python 3.7+ is required (because the wrapper is based on [asyncio](https://docs.python.org/3.7/library/asyncio.html)).
- You may need to run `pip3` instead of `pip` and `python3` instead of `python`, depending of your system defaults.
- Auterion used to have a [Getting started with MAVSDK-Python (web.archive.org)](https://web.archive.org/web/20201211155626/https://auterion.com/getting-started-with-mavsdk-python/) guide if you're a beginner and not sure where to start.
## API Reference docs
-> [API Reference documentation](http://mavsdk-python-docs.s3-website.eu-central-1.amazonaws.com/).
## Install using pip from PyPi
**Note for Raspberry Pi 1/2 and Zero:**
> MAVSDK-Python requires grpcio. However, there are no binary packets of grpcio for armv6 available via pip (also see [files on pypi.org](https://pypi.org/project/grpcio/#files)).
> In this case, install grpcio via the package manager, e.g. `sudo apt-get install python3-grpcio`.
To install mavsdk-python, simply run:
```sh
pip3 install mavsdk
```
The package contains `mavsdk_server` already (previously called "backend"), which is started automatically when connecting (e.g. `await drone.connect()`). Have a look at the examples to see it used in practice. It will be something like:
```python
from mavsdk import System
...
drone = System()
await drone.connect(system_address="udpin://0.0.0.0:14540")
```
Note: `System()` takes two named parameters: `mavsdk_server_address` and `port`. When left empty, they default to `None` and `50051`, respectively, and `mavsdk_server -p 50051` is run by `await drone.connect()`. If `mavsdk_server_address` is set (e.g. to "localhost"), then `await drone.connect()` will not start the embedded `mavsdk_server` and will try to connect to a server running at this address. This is useful for platforms where `mavsdk_server` does not come embedded, for debugging purposes, and for running `mavsdk_server` in a place different than where the MAVSDK-Python script is run.
## Run the examples
Once the package has been installed, the examples can be run:
```
examples/takeoff_and_land.py
```
The examples assume that the embedded `mavsdk_server` binary can be run. In some cases (e.g. on Raspberry Pi), it may be necessary to run `mavsdk_server` manually, and therefore to set `mavsdk_server_address='localhost'` as described above.
## Contribute
Note: this is more involved and targeted at contributors.
Most of the code is auto-generated from the [proto definitions](https://github.com/mavlink/mavsdk-proto), using our [templates](./other/templates). The generated files can be found in the [generated](./mavsdk/generated) folder. As a result, contributions are generally made in the templates or on the build system. Regularly, there is a need to update MAVSDK-Python to include the latest features defined in the proto definitions. This is described [below](#generate-the-code).
### Clone the repo
Clone this repo and recursively update submodules:
```
git clone https://github.com/mavlink/MAVSDK-Python --recursive
cd MAVSDK-Python
```
### Install prerequisites
First install the protoc plugin (`protoc-gen-mavsdk`):
```
cd proto/pb_plugins
pip3 install -r requirements.txt
```
You can check that the plugin was installed with `$ which protoc-gen-mavsdk`, as it should now be in the PATH.
Then go back to the root of the repo and install the dependencies of the SDK:
```
cd ../..
pip3 install -r requirements.txt -r requirements-dev.txt
```
### Generate the code
Run the following helper script. It will generate the Python wrappers for each plugin.
```
./other/tools/run_protoc.sh
```
### Adding support for new plugins
In case you updated the `./proto` submodule to include a new plugin, you will also have to manually edit the file `mavsdk/system.py` to register the plugin.
### Update `mavsdk_server` version
[MAVSDK_SERVER_VERSION](./MAVSDK_SERVER_VERSION) contains exactly the tag name of the `mavsdk_server` release corresponding to the version of MAVSDK-Python. When the [proto](./proto) submodule is updated here, chances are that `mavsdk_server` should be updated, too. Just edit this file, and the corresponding binary will be downloaded by the `setup.py` script (see below).
### Build and install the package locally
After generating the wrapper and only in ARM architectures with linux, defines a variable `MAVSDK_SERVER_ARCH`:
```
export MAVSDK_SERVER_ARCH=<ARM embedded architecture>
```
Supported architectures: `armv6l`, `armv7l` and `aarch64`. For example for Raspberry Pi it is `armv7l`, or `aarch64` (if a 64 bit distribution is used).
Then you can install a development version of the package, which links the package to the generated code in this local directory. To do so, use:
```
python3 setup.py build
pip3 install -e .
```
Note: MAVDSK-Python runs `mavsdk/bin/mavsdk_server` when `await drone.connect()` is called. This binary comes from [MAVSDK](https://github.com/mavlink/MAVSDK/releases) and is downloaded during the `setup.py` step above.
### Generate the API documentation
Make sure the version tag is set correctly before generating new documentation.
```
pip3 install -r requirements-docs.txt
make -C mavsdk html
```
### Release steps
1. Check the proto submodule is up-to-date and the generated code has been updated.
2. Check all required pull requests are merged to main
3. Check [MAVSDK_SERVER_VERSION](MAVSDK_SERVER_VERSION) is set to the correct version of mavsdk_server.
4. Create git tag on laster main, e.g.:
```
git switch main
git pull
git tag X.Y.Z
git push --tags
```
5. Go to [releases page](https://github.com/mavlink/MAVSDK-Python/releases) and create new release.
The CI will now:
- Create and push a wheel for Windows, Linux and macOS to PyPi.
- Generate the latest docs and push them to s3.
Raw data
{
"_id": null,
"home_page": "https://github.com/mavlink/MAVSDK-Python",
"name": "mavsdk",
"maintainer": "Jonas Vautherin, Julian Oes",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "jonas@auterion.com, julian.oes@auterion.com",
"keywords": null,
"author": null,
"author_email": null,
"download_url": null,
"platform": null,
"description": "# MAVSDK-Python\n\n[](https://github.com/mavlink/MAVSDK-Python/actions/workflows/main.yml?query=branch%3Amain)\n\nThis is the Python wrapper for MAVSDK.\n\nThe Python wrapper is based on a gRPC client communicating with the gRPC server written in C++. To use the Python wrapper the gRPC server called \"backend\" needs to be running on the same system. The wrapper is essentially auto-generated from the message definitions ([proto files](https://github.com/mavlink/MAVSDK-Proto)).\n\n\n## Important Notes\n\n- Python 3.7+ is required (because the wrapper is based on [asyncio](https://docs.python.org/3.7/library/asyncio.html)).\n- You may need to run `pip3` instead of `pip` and `python3` instead of `python`, depending of your system defaults.\n- Auterion used to have a [Getting started with MAVSDK-Python (web.archive.org)](https://web.archive.org/web/20201211155626/https://auterion.com/getting-started-with-mavsdk-python/) guide if you're a beginner and not sure where to start.\n\n## API Reference docs\n\n-> [API Reference documentation](http://mavsdk-python-docs.s3-website.eu-central-1.amazonaws.com/).\n\n## Install using pip from PyPi\n\n**Note for Raspberry Pi 1/2 and Zero:**\n\n> MAVSDK-Python requires grpcio. However, there are no binary packets of grpcio for armv6 available via pip (also see [files on pypi.org](https://pypi.org/project/grpcio/#files)).\n> In this case, install grpcio via the package manager, e.g. `sudo apt-get install python3-grpcio`.\n\n\nTo install mavsdk-python, simply run:\n\n```sh\npip3 install mavsdk\n```\n\nThe package contains `mavsdk_server` already (previously called \"backend\"), which is started automatically when connecting (e.g. `await drone.connect()`). Have a look at the examples to see it used in practice. It will be something like:\n\n```python\nfrom mavsdk import System\n\n...\n\ndrone = System()\nawait drone.connect(system_address=\"udpin://0.0.0.0:14540\")\n```\n\nNote: `System()` takes two named parameters: `mavsdk_server_address` and `port`. When left empty, they default to `None` and `50051`, respectively, and `mavsdk_server -p 50051` is run by `await drone.connect()`. If `mavsdk_server_address` is set (e.g. to \"localhost\"), then `await drone.connect()` will not start the embedded `mavsdk_server` and will try to connect to a server running at this address. This is useful for platforms where `mavsdk_server` does not come embedded, for debugging purposes, and for running `mavsdk_server` in a place different than where the MAVSDK-Python script is run.\n\n## Run the examples\n\nOnce the package has been installed, the examples can be run:\n\n```\nexamples/takeoff_and_land.py\n```\n\nThe examples assume that the embedded `mavsdk_server` binary can be run. In some cases (e.g. on Raspberry Pi), it may be necessary to run `mavsdk_server` manually, and therefore to set `mavsdk_server_address='localhost'` as described above.\n\n## Contribute\n\nNote: this is more involved and targeted at contributors.\n\nMost of the code is auto-generated from the [proto definitions](https://github.com/mavlink/mavsdk-proto), using our [templates](./other/templates). The generated files can be found in the [generated](./mavsdk/generated) folder. As a result, contributions are generally made in the templates or on the build system. Regularly, there is a need to update MAVSDK-Python to include the latest features defined in the proto definitions. This is described [below](#generate-the-code).\n\n### Clone the repo\n\nClone this repo and recursively update submodules:\n\n```\ngit clone https://github.com/mavlink/MAVSDK-Python --recursive\ncd MAVSDK-Python\n```\n\n### Install prerequisites\n\nFirst install the protoc plugin (`protoc-gen-mavsdk`):\n\n```\ncd proto/pb_plugins\npip3 install -r requirements.txt\n```\n\nYou can check that the plugin was installed with `$ which protoc-gen-mavsdk`, as it should now be in the PATH.\n\nThen go back to the root of the repo and install the dependencies of the SDK:\n\n```\ncd ../..\npip3 install -r requirements.txt -r requirements-dev.txt\n```\n\n### Generate the code\n\nRun the following helper script. It will generate the Python wrappers for each plugin.\n\n```\n./other/tools/run_protoc.sh\n```\n\n### Adding support for new plugins\n\nIn case you updated the `./proto` submodule to include a new plugin, you will also have to manually edit the file `mavsdk/system.py` to register the plugin.\n\n### Update `mavsdk_server` version\n\n[MAVSDK_SERVER_VERSION](./MAVSDK_SERVER_VERSION) contains exactly the tag name of the `mavsdk_server` release corresponding to the version of MAVSDK-Python. When the [proto](./proto) submodule is updated here, chances are that `mavsdk_server` should be updated, too. Just edit this file, and the corresponding binary will be downloaded by the `setup.py` script (see below).\n\n### Build and install the package locally\n\nAfter generating the wrapper and only in ARM architectures with linux, defines a variable `MAVSDK_SERVER_ARCH`:\n```\nexport MAVSDK_SERVER_ARCH=<ARM embedded architecture>\n```\nSupported architectures: `armv6l`, `armv7l` and `aarch64`. For example for Raspberry Pi it is `armv7l`, or `aarch64` (if a 64 bit distribution is used).\n\nThen you can install a development version of the package, which links the package to the generated code in this local directory. To do so, use:\n```\npython3 setup.py build\npip3 install -e .\n```\n\nNote: MAVDSK-Python runs `mavsdk/bin/mavsdk_server` when `await drone.connect()` is called. This binary comes from [MAVSDK](https://github.com/mavlink/MAVSDK/releases) and is downloaded during the `setup.py` step above.\n\n\n### Generate the API documentation\n\nMake sure the version tag is set correctly before generating new documentation.\n\n```\npip3 install -r requirements-docs.txt\nmake -C mavsdk html\n```\n\n\n### Release steps\n\n1. Check the proto submodule is up-to-date and the generated code has been updated.\n2. Check all required pull requests are merged to main\n3. Check [MAVSDK_SERVER_VERSION](MAVSDK_SERVER_VERSION) is set to the correct version of mavsdk_server.\n4. Create git tag on laster main, e.g.:\n ```\n git switch main\n git pull\n git tag X.Y.Z\n git push --tags\n ```\n5. Go to [releases page](https://github.com/mavlink/MAVSDK-Python/releases) and create new release.\n The CI will now:\n - Create and push a wheel for Windows, Linux and macOS to PyPi.\n - Generate the latest docs and push them to s3.\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Python wrapper for MAVSDK",
"version": "3.9.0",
"project_urls": {
"Bug Reports": "https://github.com/mavlink/MAVSDK-Python/issues",
"Homepage": "https://github.com/mavlink/MAVSDK-Python",
"Source": "https://github.com/mavlink/MAVSDK-Python/"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "efcd43d59830cce10c59f47aab771ff768d5c9001c0d24a94b032ee25b06aa79",
"md5": "64a408f4ac7fe91e22d58272a4800b95",
"sha256": "a4d34722d516c63830722e1c6fc19537a4094f2ec4c4499c507c649bb887c5d6"
},
"downloads": -1,
"filename": "mavsdk-3.9.0-py3-none-linux_armv6l.whl",
"has_sig": false,
"md5_digest": "64a408f4ac7fe91e22d58272a4800b95",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 16257348,
"upload_time": "2025-08-01T19:31:10",
"upload_time_iso_8601": "2025-08-01T19:31:10.724340Z",
"url": "https://files.pythonhosted.org/packages/ef/cd/43d59830cce10c59f47aab771ff768d5c9001c0d24a94b032ee25b06aa79/mavsdk-3.9.0-py3-none-linux_armv6l.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "5e764d3354976c1acf5135a6b860f943cda5630c05278bfa39c8a983cb41dd50",
"md5": "d417e52856a389ec4df250880be6b2aa",
"sha256": "6a3daf144d668977f40dc0071f42abdff0f382c4ac34202c34510f55a30ebd63"
},
"downloads": -1,
"filename": "mavsdk-3.9.0-py3-none-linux_armv7l.whl",
"has_sig": false,
"md5_digest": "d417e52856a389ec4df250880be6b2aa",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 16257145,
"upload_time": "2025-08-01T19:31:09",
"upload_time_iso_8601": "2025-08-01T19:31:09.549476Z",
"url": "https://files.pythonhosted.org/packages/5e/76/4d3354976c1acf5135a6b860f943cda5630c05278bfa39c8a983cb41dd50/mavsdk-3.9.0-py3-none-linux_armv7l.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8abc42f05030e120649493fc4e230e43e35c260966747db23409272389702873",
"md5": "f64d7224bd0cf2d3c17b1702fbc05c5c",
"sha256": "0c0c5326be0957ca5ef995813170042d0fd58c1d10dcafff011630309e62c7b0"
},
"downloads": -1,
"filename": "mavsdk-3.9.0-py3-none-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "f64d7224bd0cf2d3c17b1702fbc05c5c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 12257611,
"upload_time": "2025-08-01T19:31:26",
"upload_time_iso_8601": "2025-08-01T19:31:26.998558Z",
"url": "https://files.pythonhosted.org/packages/8a/bc/42f05030e120649493fc4e230e43e35c260966747db23409272389702873/mavsdk-3.9.0-py3-none-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8b90eb029d177c8cde759dfc855b792005b1b88f4eedacd3e1aefd0651b6f825",
"md5": "6b9fa2b13911c83520908b11c419b833",
"sha256": "f7c8976cc8af2da74bba1fa102f573ec5cf0a25e41a6bf19de47e2fac7da63b4"
},
"downloads": -1,
"filename": "mavsdk-3.9.0-py3-none-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "6b9fa2b13911c83520908b11c419b833",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 12137365,
"upload_time": "2025-08-01T19:31:25",
"upload_time_iso_8601": "2025-08-01T19:31:25.413186Z",
"url": "https://files.pythonhosted.org/packages/8b/90/eb029d177c8cde759dfc855b792005b1b88f4eedacd3e1aefd0651b6f825/mavsdk-3.9.0-py3-none-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a65c882610b7f85576db37bb2f362d0f76a9add12e20f7bb652aa74318f48555",
"md5": "0a502df5d0696b955d901ed295998706",
"sha256": "83e830ec8f1d892f2ddda6f5fe78d3692737dbb246ceb7b3e4059014f31a4643"
},
"downloads": -1,
"filename": "mavsdk-3.9.0-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl",
"has_sig": false,
"md5_digest": "0a502df5d0696b955d901ed295998706",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 14881706,
"upload_time": "2025-08-01T19:31:26",
"upload_time_iso_8601": "2025-08-01T19:31:26.116327Z",
"url": "https://files.pythonhosted.org/packages/a6/5c/882610b7f85576db37bb2f362d0f76a9add12e20f7bb652aa74318f48555/mavsdk-3.9.0-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d7d7f7e065bae77ea5ae3adc674f0ec257efa8d568bb2da4894f5b3b72c81240",
"md5": "b97a67faed4dff47cf0ca01720a53802",
"sha256": "d5865675faf992eb4d3f3a77603aadc433d90a6215b983e789f403fe6bafffc5"
},
"downloads": -1,
"filename": "mavsdk-3.9.0-py3-none-manylinux2014_aarch64.whl",
"has_sig": false,
"md5_digest": "b97a67faed4dff47cf0ca01720a53802",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 17846263,
"upload_time": "2025-08-01T19:31:16",
"upload_time_iso_8601": "2025-08-01T19:31:16.070115Z",
"url": "https://files.pythonhosted.org/packages/d7/d7/f7e065bae77ea5ae3adc674f0ec257efa8d568bb2da4894f5b3b72c81240/mavsdk-3.9.0-py3-none-manylinux2014_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0316e2cf79fa000403177451958c2927151e63fe59a7af0b1a3751edd9f869ea",
"md5": "ef6ed7c774c970bfeb7c7094def6e540",
"sha256": "b87d7d88552a739e68a181a1f693d0caed5cb776e35099524ac02b9ec46cdaf4"
},
"downloads": -1,
"filename": "mavsdk-3.9.0-py3-none-win32.whl",
"has_sig": false,
"md5_digest": "ef6ed7c774c970bfeb7c7094def6e540",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 10078779,
"upload_time": "2025-08-01T19:31:40",
"upload_time_iso_8601": "2025-08-01T19:31:40.066690Z",
"url": "https://files.pythonhosted.org/packages/03/16/e2cf79fa000403177451958c2927151e63fe59a7af0b1a3751edd9f869ea/mavsdk-3.9.0-py3-none-win32.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "6827b2b27f761006254cdf6200ce704d26ef587ac8b95bc329d33e9ac8373096",
"md5": "e87d4e56a23646a9ac84b3f510b42887",
"sha256": "ae40c6785c775c4a3c33de184baaaf5faed3002e4a6e7bc03a52f9f93b6ba56f"
},
"downloads": -1,
"filename": "mavsdk-3.9.0-py3-none-win_amd64.whl",
"has_sig": false,
"md5_digest": "e87d4e56a23646a9ac84b3f510b42887",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 10078779,
"upload_time": "2025-08-01T19:31:39",
"upload_time_iso_8601": "2025-08-01T19:31:39.492019Z",
"url": "https://files.pythonhosted.org/packages/68/27/b2b27f761006254cdf6200ce704d26ef587ac8b95bc329d33e9ac8373096/mavsdk-3.9.0-py3-none-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "be62fb513d1b412feeba0c45e8cca5694bfd79a5075daa1edacf05a8904263d1",
"md5": "36cd56399292c14cdad0c3378e74795d",
"sha256": "729b048f50d1d814d335e87d608da896f4ea3308a08e4f630b8b8ac9eedf734b"
},
"downloads": -1,
"filename": "mavsdk-3.9.0-py3-none-win_arm64.whl",
"has_sig": false,
"md5_digest": "36cd56399292c14cdad0c3378e74795d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 10078779,
"upload_time": "2025-08-01T19:31:31",
"upload_time_iso_8601": "2025-08-01T19:31:31.966390Z",
"url": "https://files.pythonhosted.org/packages/be/62/fb513d1b412feeba0c45e8cca5694bfd79a5075daa1edacf05a8904263d1/mavsdk-3.9.0-py3-none-win_arm64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-01 19:31:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mavlink",
"github_project": "MAVSDK-Python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "protobuf",
"specs": [
[
">=",
"5.27.1"
]
]
},
{
"name": "grpcio",
"specs": [
[
">=",
"1.64.1"
]
]
}
],
"tox": true,
"lcname": "mavsdk"
}