No Module Named 'em', 'numpy' Errors Ubuntu 18.04

I’m running Ubuntu 18.04 on a paperspace machine, default Python 3.6.

I’ve installed the PX4 Firmware, and now I’m trying to run PX4 using

make px4_sitl gazebo and I get errors that ‘em’, and ‘numpy’ have not been installed. I suspected that this is an issue with python version. I ran sudo update-alternatives --config python and switched to Python 3.6 to force PX4 to build using Python 3, and also changed $ROS_PYTHON_VERSION to 3.

This worked on another machine, but not on this machine. I have run pip3 install -- user em successfully, but when I run the make command, the Modules are still not recognized as being installed. I have run this with both version of python.

Any help appreciated!

Can you try:

pip3 install --user empy numpy

And if it doesn’t work please paste the output of this here:

which python
which python3
which pip
which pip3
python --version
python3 --version
pip --version
pip3 --version

Despite running pip3 install --user empy, and pip3 install --user numpy individually, running them together as pip3 install --user empy numpy returned

ERROR: keras-preprocessing 1.0.3 requires keras>=2.1.6, which is not installed.
ERROR: keras-preprocessing 1.0.3 requires scipy>=0.14, which is not installed.

So I ran
pip3 install --user empy numpy keras
and then ran

make px4_sitl gazebo

again which returned:

Failed to import packaging: No module named 'packaging'

You may need to install it using:
    pip3 install --user packaging

So I ran that pip command and make again with a lot of progress, but now I have

-- Configuring incomplete, errors occurred! See also "/home/paperspace/src/Firmware/build/px4_sitl_default/build_gazebo/CMakeFiles/CMakeOutput.log". See also "/home/paperspace/src/Firmware/build/px4_sitl_default/build_gazebo/CMakeFiles/CMakeError.log". [395/401] Linking CXX executable bin/px4 FAILED: external/Stamp/sitl_gazebo/sitl_gazebo-configure cd /home/paperspace/src/Firmware/build/px4_sitl_default/build_gazebo && /usr/local/lib/python3.6/dist-packages/cmake/data/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DSEND_VISION_ESTIMATION_DATA=ON -GNinja /home/paperspace/src/Firmware/Tools/sitl_gazebo && /usr/local/lib/python3.6/dist-packages/cmake/data/bin/cmake -E touch /home/paperspace/src/Firmware/build/px4_sitl_default/external/Stamp/sitl_gazebo/sitl_gazebo-configure [397/401] Linking CXX executable bin/px4 ninja: build stopped: subcommand failed. Makefile:205: recipe for target 'px4_sitl' failed make: *** [px4_sitl] Error 1

To answer your questions
which python : /usr/bin/python
which python3: /usr/bin/python3
which pip: /home/paperspace/.local/bin/pip
which pip3: /home/paperspace/.local/bin/pip3
python --version: Python 3.6.9
python3 --version Python 3.6.9
pip --version: pip 19.2.1 from /home/paperspace/.local/lib/python3.6/site-packages/pip (python 3.6)
pip3 --version: pip 19.2.1 from /home/paperspace/.local/lib/python3.6/site-packages/pip (python 3.6)

If I change to python 2.7 python --version returns : Python 2.7.17

It looks like the build (almost) worked now.

What’s the last error when it builds sitl_gazebo?

It looks like it was actually a GSTREAMER_LIBRARIES issue, which I have dealt with before on the other machine running 18.04 and solved by looking at a reply from one of your devs on github.

I ran

sudo apt-get install libgstreamer-plugins-base1.0-dev

and the make worked!

Thanks for such quick and knowledgeable replies.

So, full solution

pip3 install --user empy numpy keras packaging
sudo apt-get install libgstreamer-plugins-base1.0-dev

Thanks again!

1 Like

For anyone seeing this and wondering: keras is not actually a dependency of PX4. This was probably just somehow leftover.

I could be wrong, but I think the keras dependency may have been related to numpy?