[Bug] how to fix this rosrun problem

This is an error report.


Screenshot of the error


Error details

how to fix this rosrun problem as only move_bb8_square.py is not working with rosrun but instead it is working with python

I think you have two different python scripts with the same name. Or maybe the same move_bb8.py file but duplicated. One in move_bb8_pkg/src and the other in move_bb8_pkg/my_scripts

it means that there are multiple executables with the same name in different packages. This can occur if:

  1. There are multiple packages installed that contain an executable with the same name.
  2. The executable you are trying to run has been built in different locations.

so in other terms you have the move_bb8_square.py in multiple locations built as executable

the command is rosrun <package_name><executable_name> so make sure to have the correct package name (a ros package is different than a normal folder)

try to remove any instance of the python file except in your package

Hi @8853897079, to complement the given answers you have to make sure also that the Python script has executable permissions:

chmod +x move_bb8_square.py

Also, Check the Shebang (Interpreter Line): The first line of your Python script should specify the Python interpreter. Ensure your script starts with:

#!/usr/bin/env python3

And the most important you have to make sure that you included the script in the CMakeLists.txt and you compiled and sourced:

install(PROGRAMS
  src/move_bb8_square.py
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.