Error trying to start ardupilot

I am getting an error when trying to start my ardupilot build.
When I run:

sim_vehicle.py -w

I get the error:

Traceback (most recent call last):
  File "/home/mikeyjoyce/ardupilot/Tools/autotest/sim_vehicle.py", line 31, in <module>
    from pysim import util
  File "/home/mikeyjoyce/ardupilot/Tools/autotest/pysim/util.py", line 16, in <module>
    import pexpect
ImportError: No module named pexpect

Which is strange since pexpect is installed on my system which is proved by the following command and output:

pip3 show pexpect

And the output:

Name: pexpect
Version: 4.8.0
Summary: Pexpect allows easy control of interactive console applications.
Home-page: https://pexpect.readthedocs.io/
Author: Noah Spurrier; Thomas Kluyver; Jeff Quast
Author-email: noah@noah.org, thomas@kluyver.me.uk, contact@jeffquast.com
License: ISC license
Location: /home/mikeyjoyce/.local/lib/python3.6/site-packages
Requires: ptyprocess

Try this instead:

pip show pexpect

Your system may have 2 python installs (python/pip and python3/pip3) - so best to check both.

When I run

pip show pexpect

I get the following output:

Command 'pip' not found, but can be installed with:

sudo apt install python-pip

Also I forgot to mention the operating system that I am running is Ubuntu 18.04

Seems maybe you have the package installed locally for a virtual environment rather than globally.

How do I install globally?

I was able to get past it with the following command:

sudo apt install python-matplotlib python-serial python-wxgtk3.0 python-wxtools python-lxml python-scipy python-opencv ccache gawk python-pip python-pexpect

But now I have a problem still with

sim_vehicle.py -w

The output says:

Traceback (most recent call last):
  File "/home/mikeyjoyce/ardupilot/Tools/autotest/sim_vehicle.py", line 31, in <module>
    from pysim import util
  File "/home/mikeyjoyce/ardupilot/Tools/autotest/pysim/util.py", line 18, in <module>
    from pymavlink.rotmat import Vector3, Matrix3
ImportError: No module named pymavlink.rotmat

I have installed pymavlink with pip

You can try using this script.

Yeah, I did that script. I eventually got it working I think @stephendade was correct in my system having python 2 also on the system. I just installed the prereqs for each python version

I had this problem because of two different versions of Python on my machine. One is Python 2.7 and the other is Python 3.8.

My solution is use Python 3.8 as the default one for my machine by running
sudo ln -sf /usr/bin/python3.8 /usr/bin/python