Skip to main content
1 of 7

I am a beginner at ROS, what I post here are just ideas, a bit too long text for Stack Exchange, but I see that this question is not yet solved after a long time - the answer does not solve the issue in my case - which makes it possible to stand a bit against the rules, rather documenting ideas than answering clearly.

I am still working on the error, perhaps I will find out more and add it here. The fact is that I had (and can have any time again) a running system when I just strictly follow a clear list of commands. Yet, when I I installed everything again on another computer and "played around" a bit, probably introduced different Python versions for pip and used different venv or no venv during installation and other small differences from the guide, I could not get it to run. I guess that the main PATH variable for pip is changing so that you need pip3 vs pip, and then the way something was installed changes the picture, most promising research here is https://answers.ros.org/question/204024/no-module-named-catkin_pkgpackage-on-catkin_make-w-hydro/.

ROS now supports pip3 so why installing another pip at all, that might be dangerous. Take pip3 as the pip. On the other hand, you might as well take only pip of python2.7 and have success as well (perhaps): for any pip installation using python2.7 -m pip install [package_name] so that it can be excluded that catkin uses > 2.7 is perhaps outdated, but could work for projects older than a year. And that is even realistic if you work for example on melodic.

On the whole, I expect a conflict of various python installations (I have 2.7, 3.6, 3.7 installed), with the venv 2.7 that is using packages that were installed with 3.7 perhaps. Since this catkin_pkg is definitely installed in all three, it is possible that catkin_pkg rather needs the python version 2.7 that it was built against but chooses the catkin_pkg from the 3.7 folder instead. Or the other way round, who knows.

Or there is a completely unexpected thing like this comment of a developer at http://lists.ros.org/pipermail/ros-users/2015-October/069721.html in 2015:

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.

Thus it could be that apt-get does not at all care about any python version. That would mean that you should install as much as possible with apt-get to avoid any Python version conflicts. But that is from development times in 2015, probably not relevant anymore as this already explained the error in 2015, with a fix.

Quoting something else from https://answers.ros.org/question/340510/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. As Python 3 is now supported by ROS, the idea comes up that this happens when you use a python2 pip to install kinetic / melodic / indigo and then switch to python3 packages.

Just guessing from (and with further ideas):

Thank you for the patience.