# Running MAVSDK directly on M500 and Python update

Source: https://forum.modalai.com/topic/2010/running-mavsdk-directly-on-m500-and-python-update
Category: Development Drones (https://forum.modalai.com/category/44/development-drones)
Tags: m500
Posted: 2023-03-29 02:32:49 UTC by Steve Sager
Replies: 6 · Views: 1739

## Steve Sager · 2023-03-29 02:32:49 UTC

The team and I are developing a learning AI algorithm deployed on a raspberry pi to fly an obstacle course with the M500. We are only using the Hires camera frames and aircraft position data. 
We wanted to run our python code directly on your VOXL flight deck, but I'm having trouble updating the python version on the M500. Our AI is running on Ubuntu 20.04 with Python 3.9.15. Any way we can update this to something closer to 3.9?
I also am using python based MAVSDK commands from the AI to control movement through the obstacle course, do you know if we can run this directly on the system as well?
We are aware of the docker option and would just like to know if we can run on the aircraft without docker, or if we should go ahead and set up what we need to run in a docker container.
Any feedback on the two questions is appreciated!

Kind Regards,
Steve

## Reply by Chad Sweet (ModalAI staff) · 2023-03-29 02:40:05 UTC

Have you looked at the tutorial on MAVSDK? https://docs.modalai.com/mavsdk

## Reply by Alex Kushleyev (ModalAI staff) · 2023-03-29 05:01:34 UTC

You should be able to build python3 from source on target, for example i used the following instructions to build python 3.8.16 on VOXL1 Flight
```
mkdir ~/python-build
cd ~/python-build
wget https://www.python.org/ftp/python/3.8.16/Python-3.8.16.tgz
tar xzf Python-3.8.16.tgz
cd Python-3.8.16
./configure --enable-optimizations
make -j 8
make altinstall

~ # python3.8 --version
Python 3.8.16
```

It took like 20 minutes to build it on VOXL1 -- tests took a while which generate some data for optimizations (`--enable-optimizations` enables this).

You can build newer versions of Python using the same approach too, just check the path of .tgz archive (you can browse the http)

## Reply by Steve Sager · 2023-03-29 16:30:45 UTC (in reply to Chad Sweet)

@Chad-Sweet 
Thanks for the quick reply, our team looked into the docker examples, and know that is an option. We are looking to run MAVSDK python directly on M500's VOXL.
We'll use docker if this cannot be done, since we need the architecture bloating to stay as low as possible due to the AI.

## Reply by Chad Sweet (ModalAI staff) · 2023-03-29 16:35:18 UTC

The Docker is 64-bit, so the code that runs inside is usually faster than the code that runs outside of the Docker

## Reply by Steve Sager · 2023-03-29 17:02:51 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev 
Thanks a bunch for the quick guide we are successful in upgrading our system to the desired 3.9.15 python version. 
Would we be able to follow the same steps for MAVSDK python install to M500?
We are trying to run MAVSDK python files directly in the VOXL data folder currently and receiving an invalid syntax error on the "async def run()" line. I was under the impression we had MAVSDK in the aircraft already from the functional diagram on the docs shown in the MAVSDK link.
https://docs.modalai.com/mavsdk/
Do we need to install Asyncio too to fix this error?

## Reply by Steve Sager · 2023-03-29 17:05:33 UTC (in reply to Chad Sweet)

@Chad-Sweet said in [Running MAVSDK directly on M500 and Python update](/post/9354):
> The Docker is 64-bit, so the code that runs inside is usually faster than the code that runs outside of the Docker

Oh, that's interesting, thanks for the insight. I'll share with the others, and let you know how it all goes.
