The core reason behind No module named 'roslaunch'
Problem
You’re running or launching some ROS package, but you see an error message such as
No module named 'roslaunch'
Reason
The core reason for this is that roslaunch
is from ROS 1, whereas you’re using ROS 2.
Therefore, you must be mixing ROS 1 and ROS 2 packages in some way.
The next step for you would be to find out which package uses roslaunch
and then find a ROS 2 equivalent for that package.
/home/uli/.local/lib/python3.12/site-packages/xacro/init.py
ag -i roslaunch
Sometimes this happens because you’ve installed Python packages somewhere (outside the main ROS2
directory, for example using pip
) and these ROS1 packages are still in your PYTHONPATH
.
In case you are using ros2 launch
, see our post ROS2 hack to enable DEBUG logging during ‘ros2 launch’ for an easy hack to see the stacktrace where roslaunch
is being imported from.
In my case, I installed a copy of xacro
to ~/.local/lib/python3.12/site-packages/xacro/__init__.py
.
Therefore, I needed to uninstall xacro
using
pip uninstall xacro
and then install the ROS2 version of xacro
using
sudo apt -y install ros-jazzy-xacro