Home        Store        Docs        Blog

Python 3 support for pymavlink


(Brad) #1

I have some image processing code that will only run in Python 3 that I need to use with our vehicle. We have written some RC controller code that works fine in Python 2.7, but not in Python 3.

I am using pymavlink and specifically mavuitl.rc_channels_override_send() to control the motors. Running the code in Python 2 moves the motors as expected, but using the exact same code in Python 3 I get no response from the motors and no error messages in the terminal. I have a virtual environment setup, and there do not appear to be any errors during installation of pymavlink or other dependencies. pip freeze shows the following after installation for both Python 2 and 3:

future==0.16.0
lxml==4.2.1
pymavlink==2.2.8
pyserial==3.4

Any help is much appreciated! Thanks!


(Brad) #2

Looks like I have answered my own question, but downloading mavlink and building pymavlink from scratch appeared to solve the problem. It still claims to be version 2.2.8, but now it works properly with python 3. If anyone has an idea on how to get the PyPI python 3 version of pymavlink to work, it would be appreciated. For now, building from scratch appears to be a good stopgap.


(Patrick José Pereira) #3

I’m glad that you figured it out :slight_smile:

Are you using pip from python3 ?

pip --version
pip 9.0.1 from /usr/lib/python3.6/site-packages (python 3.6)
pip2 --version
pip 9.0.1 from /usr/lib/python2.7/site-packages (python 2.7)

You can install pymavlink with any version of pip :slight_smile:


(Brad) #4

I’m on a Raspberry Pi, so I’m limited to Python 3.4, but yes my pip is the version for python3.4 afaik.

(venv) $ pip3 --version
pip 10.0.1 from /home/pi/projects/controller/venv/lib/python3.4/site-packages/pip (python 3.4)