No module named pymavlink ERROR

when trying to run:

sim_vehicle.py -w

I am getting an error saying:

Traceback (most recent call last):
File “/home/odroid/ardupilot/Tools/autotest/sim_vehicle.py”, line 25, in
from pymavlink import mavextra
ImportError: No module named pymavlink

I was wondering if anyone has come across this error or knows what I am needing to do to stop this from happening. Thanks.

you can install pymavlink with pip

pip install -U pymavlink

a search in the ardupilot source code found this:

modules/mavlink/README.md
13:* Source: Mavlink Generator
14:* Discussion: Gitter Channel

I just happened to need the latest version of ardupilot, so i cloned the repo again. After the initial git clone command you need to cd to the ardupilot directory and run:
git submodule update --init --recursive

That will sync and download various submodules need by ardupilot, and I noticed pymavlink was one of them.

I did the pip install. Now I am left with this error.

RiTW: Starting APMrover2 : /home/odroid/ardupilot/build/sitl/bin/ardurover -S -I0 --model rover --speedup 1 --defaults /home/odroid/ardupilot/Tools/autotest/default_params/rover.parm
[Run MavProxy] An exception has occurred with command: ‘mavproxy.py --master tcp:127.0.0.1:5760 --sitl 127.0.0.1:5501 --out 127.0.0.1:14550 --out 127.0.0.1:14551 --map --console’
[Errno 2] No such file or directory
SIM_VEHICLE: Killing tasks

you need to update the submodules under ardupilot:

after git cloning, cd to ardupilot directory and run
git submodule update --init --recursive

that will download many more modules needed by ardupilot, including the python scripts you are missing.

you should also run git submodule update --recursive after updating ardupilot, for example when checking out a branch or running git origin pull.

when I do either of the commands you say it does not show anything on my screen. I hit enter and then it just goes straight to the next line waiting for another command. Thanks

also after I run sim_vehicle.py -w -v ArduCopter. I get that output still but I forgot to say that I get another screen called ArduCopter and it says stuff and the last line is waiting for connection…

what directory are you running the command from? I need to look into running SITL. Did you have to build ardupilot first? Without submodules the build should have failed.

it is working now for some reason.

It takes a couple of minutes to start on my laptop. If necessary you can install mavproxy with pip.

I’m having this same error. When I try and run git submodule update --init --recursive I get this:

From https://github.com/DroneCAN/libuavcan
 * branch              3ef4b88d96466bbcf886f74d0ae169a4c8c1bdb0 -> FETCH_HEAD
Fetching submodule dsdl
fatal: remote error: upload-pack: not our ref 192295c4f9b67f4a20b0eabf74757b6597415f2b
fatal: the remote end hung up unexpectedly
Fetched in submodule path 'modules/uavcan', but it did not contain 3ef4b88d96466bbcf886f74d0ae169a4c8c1bdb0. Direct fetching of that commit failed.

Hi Ben,

Out of interest try to run the following file,

./Tools/gittools/submodule-sync.sh

2 Likes

OK, I have run that. Now I don’t get an error mentioning uavcan, just module not found (future or pymavlink, depending on whether I run python3 sim_vehicle from the autotest directory, or just sim_vehicle.py from any other directory).

I think this is a pythonpath issue:

  • When I run “which python3” I get /usr/bin/python3
  • When I run “which pip3” I get /usr/local/bin/pip3

How can I move/point pip/pip3 to the same place as python/python3? This is a fresh installation and I’m confused why pip is in /usr/local

Definitely do what python says, I believe it is pip install future

I’m not a python install expert but here is my info. below.

(base) veritas@DESKTOP-V9LAGA3:~/ardupilot$ which python3
/usr/bin/python3
(base) veritas@DESKTOP-V9LAGA3:~/ardupilot$ which pip3
/home/veritas/.local/bin/pip3

Would you push to text file all of your errors and the command used?

What is your os? What computer you are using on? I got it working on most os except for some SBC with vendor customized os.