Pymavlink installation on Ubuntu18.04

I encountered some installation failure when I tried to set up mavlink in Ubuntu18.04. I followed this guidance: Pymavlink · GitBook
the default python version was 2.7, and 3.6 was also equiped.
I started with 2.7, pip3 install was successful, but I could not import it in python.
later I tried to upgrade python version, where I messed up with the ubuntu system. Luckily, not so much file loss.
The windows installation was just fine, but I still would prefer to frequently do coding in Ubuntu, or Debian for RPi.
So, the problem is, do I need to set up a virtual environment in Ubuntu and install it with at least python3.8 or later versions?

Hi @Lili_Marleen,

Pymavlink should work on both Python 2 and Python 3. pip3 installs libraries to Python 3, so understandably installing a library to Python 3 (python3) and then trying to import it into a Python 2 (python) session won’t work.

That’s not a requirement, but in the interests of being able to use the most recent Python features it may be something you want to do. I believe all of our current Pymavlink examples (on the page you linked to) should be compatible with Python 2.7 and above, but our Companion Beta software uses Python 3.9, and new/advanced examples we provide may not maintain compatibility with older versions of Python.

Personally I quite like many of the new language features, so my own examples (like this gist) tend to assume Python 3.8 or higher by default. That said, we’re still able to help with questions/testing things with earlier versions of Python as necessary, so if for some reason you need to stay on an older system you should still be able to get support :slight_smile:

Out of interest, is there a particular reason you’re using Ubuntu 18.04 instead of 20.04 (the latest stable, which comes with Python 3.8 by default)?