On further review, it appears the imp module has been deprecated and removed in python 3.12, the default version of python in Ubuntu 24.04. The module imp has been replaced by importlib. Does this mean an update is needed to the ardupilot repo? Should I try installing an older version of python to get it to work?
If you don’t have an ArduPilot virtual environment configured in Ubuntu 24.04, you will likely run into issues. I don’t think module deprecation under Python 3.12 is the root cause.
Have you run install-prereqs-ubuntu.sh?
For example, using a very similar environment on a recent Arch Linux install with Python 3.12.5, if I do not activate the venv, I get the following output:
$ sim_vehicle.py -v ArduCopter --no-mavproxy
Traceback (most recent call last):
File "/home/myusername/ardupilot/Tools/autotest/sim_vehicle.py", line 31, in <module>
from pysim import util
File "/home/myusername/ardupilot/Tools/autotest/pysim/util.py", line 19, in <module>
import pexpect
ModuleNotFoundError: No module named 'pexpect'
But as soon as I activate the venv, all is well.
I have also recently used Ubuntu 24.04 without any problems, though I’ve largely abandoned Ubuntu for reasons that have nothing to do with this particular issue (even the most lightweight server edition installations are just too bloated, IMHO).
Thank you Yuri. I ran ‘install-prereqs-ubuntu.sh’ and venv but no luck. I am still getting the same message running sim_vehicle.py.
Specifically, I followed these steps 1) installed Ubuntu 24.04 on virtualbox, 2) installed a bunch of dependencies, 3) downloaded and installed install-prereqs-ubuntu.sh, 4) installed various python packages using ‘pip-install --break-system-packages ’, 5) created my directories and ArduCopter using the git repo, 6) installed and activated venv, 7) Ran sim_vehicle.py.
That sounds like too many steps. You shouldn’t need to globally install any pip modules or one-off dependencies. Yes, things have changed since Ubuntu 22.04. But if you clone the repo and update submodules, then run the script, you should have a venv available to activate (created by the script and not named “myvenv”). And it works first time every time.
I am running python dronekit and pymavlink programs, so my dependencies include:
numpy, opencv, wxgtk, matplotlib, libxml2, libxslt-dev, scipy, pexpect future, screen
The pip modules are
pygame, pyyaml, mavproxy, pymavlink, empy, dronekit, dronekit-sitl
Does this not seem correct? I was told by an IT guy that since python3.12 there are package management conflicts, and to use the --break-system-packages statements.
What are the general steps you use to build your copter sitl?
Once I get this sorted, I would also like to try out Arch Linux.
You are blindly running a whole lot of extra commands that make little sense.
You don’t need just any venv, you need to source the one located at venv_ardupilot, which should have been created in the same directory as your ArduPilot clone (which, by the sounds of it, you may have cloned incompletely…).
use a release with pthon 3.11 (x64) and unzip it, so it replaces the preinstalled ardupilot python venv next to your ardupilot folder in venv-ardupilot
after that you can run e.g. .waf clean inside the ardupilot folder which might prompt you to install additional python packages, install them until it runs like