Skip to main content
6 of 7
added 87 characters in body

I found the solution by many tries. It is not guaranteed that it will help you, in my case, this helped.

But why do I need to have python -m pip -V = 2.7 only in order to get rid of that error?

  • The standard python -m pip command after having applied sudo apt-get install python-pip under Python 2.7 seems important. python -V must be Python 2.7.17 or the like. This is probably because the catkin installer simply needs the old pip as the standard assignment, in my case in order to deal with gazebo.
  • By the same time it seems important that sudo apt-get install python3-pip is installed as well, which is then installed automatically under Python 3.6.

This comment of a developer already in 2015 explains why 3.6 is installed even if you have another version like 3.7 or the like installed:

The issue you're running into is that the Python that is turned on by default is a non-system Python 2.6 install which is unaffected by installing Python packages with apt-get. By using the minimal image you avoid having to deal with custom versions of Python.

The old standard 2.6 has now become 3.6; if you install with apt-get, 3.6 will likely be installed. But if you install python-pip instead of python3-pip, it will use a python 2.7 version by default.

apt-get does not at all care about any python version that you already have. That would mean that one should install as much as possible with apt-get to avoid any Python version conflicts / have an independent install. And using pip should at best be clear by putting the needed python -m / python3.7 -m / ... in front.

Quoting something else from catkin_make: No module named 'catkin_pkg':

You'll either have to install catkin_pkg (and a few others) for the Python 3 interpreter (using the pip3 command shown by @...), or make sure Catkin uses the Python 2 interpreter.

My recommendation would be the latter, as the rest of Melodic will also have been built against Python 2. Not Python 3.

The next release of ROS 1 (Noetic) will support Python 3.

This was in 2019. In 2020, Python 3 is now supported by ROS, but that does not mean that a project that has started in 2019 supports it entirely. So better keep to python2.7 for pip and most of the installations that you do for a project that has started in 2019 and has cmake errors.

Further ideas: