I found the solution by many tries. It is not guaranteed that it will help you, in my case, this helped.
- A good start was "No module named catkin_pkg.package" on catkin_make w/ Hydro.
- The main steps are already documented at a rather neighboured thread of Installing OpenCV fails because it cannot find “skbuild”.
But why do I need to have python -m pip -V
= 2.7 onlyand be in the Python base environment in order to get rid of that error?
- The standard
python -m pip
command after having appliedsudo apt-get install python-pip
under Python 2.7 seems important.python -V
must bePython 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. - If you are in a virtual environment, the configuration of the base environment that is used by the installer is conflicting with versions that are installed in the virtual environment.
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: