No module named 'rospkg'

Hello Everyone,

I want to implement the Ros on the stretch robot 2. but when i launch the ros i have following error

"substitution args not supported: No module named ‘rospkg’ "

I am using the following command
roslaunch stretch_core stretch_driver.launch.

I have Screenshot of the screen

1 Like

This issue has been resolved through a mail thread.
The reason for the error No module named 'rospkg' was because the user had Miniconda installed and the (base) conda environment activated. Therefore the ros python packages installed through linux apt install will not be visible to the python3 interpreter in the conda environment.
When a conda environment is activated, Python3 will point to the virtual environment interpreter (~/miniconda3/bin/python3) instead of the system interpreter (/user/bin/python3). Generally, it is advised not to use miniconda virtual environments for running ROS nodes because it overrides a lot of system python3 interpreter configurations that are hard to resolve.

I can imagine a few approaches for this issue:

  1. You can simply exit out of the miniconda virtual environment and do roslaunch that uses the system python3 interpreter:

    • Exit the base virtual environment using the command: conda deactivate (You should be able to observe (base) tag in the terminal disappear)
    • You could continue developing your projects without miniconda virtual environments
    • You can use the command which python3 to check where the python3 sym link points to.
  2. Another drop-in alternative to Miniconda is using Mamba with Robostack that allows you to create virtual environments through conda with ROS installations specific to the environment. And then source the catkin_ws into the environment and roslaunch stretch driver node.

    • You can try out these consolidated commands to set up a Ros noetic with conda environment through Mamba and run the Stretch driver node.
# Install Mambaforge
# Create a ROS environment
mamba create -n ros_env
mamba activate ros_env
conda config --env --add channels conda-forge
conda config --env --add channels robostack-staging
conda config --env --remove channels defaults
mamba deactivate; mamba activate ros_env
# Install ROS Noetic
mamba activate ros_env
mamba install ros-noetic-desktop
mamba deactivate; mamba activate ros_env
# Run Stretch Driver Node from the ROS environment
mamba activate ros_env
source ~/catkin_ws/devel/setup.bash
roslaunch stretch_core stretch_driver.launch
  • You can read the Robostack documentation for a better understanding.
  • Note: This method is untested, and we don’t have direct support for these virtual environments yet.
1 Like