ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ros2 run python executable not found

asked 2018-08-01 04:26:03 -0600

aks gravatar image

updated 2018-08-01 04:26:23 -0600

I am working with ROS2 ardent, using Colcon to build.

The build is suceessful and I can also see my executable in <ws/build/package-name/build/lib/> but still when I run the package using ros2 run, no executables are found.

edit retag flag offensive close merge delete


Did you source the setup.bash file in the install folder ?? source <ros2_ws>/install/setup.bash You can add the command to ~/.bashrc so that you don't have to source every time you open a terminal.

Marc Testier gravatar image Marc Testier  ( 2018-08-01 04:33:35 -0600 )edit

Yes, I have sourced the setup.bash file, still no executable found

aks gravatar image aks  ( 2018-08-01 04:39:38 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2018-08-01 05:01:19 -0600

aks gravatar image

I found the problem.

In the file, I had a missing , for the last node in the entry pointsi.e.

    'console_scripts': [
        'listener = demo_nodes_py.topics.listener:main',
        'talker = demo_nodes_py.topics.talker:main'
        'listener_qos = demo_nodes_py.topics.listener_qos:main'

NOTE :  The missing `,` before the `listener_qos` node.

The strange thing here is, compiler compiles all the 3 nodes and I can see in the <ws/build/package-name/build/lib/> folder. Shouldnt the compiler just ignore the 3rd node listener_qos in this case ?

edit flag offensive delete link more

answered 2022-01-26 15:28:28 -0600

AndyZe gravatar image

updated 2022-01-26 15:36:04 -0600

I have a mixed C++/Python package. To install a Python executable in this package, I've found it sufficient to do this:

  • Add the Python source file to my_package/scripts
  • Add this line at the top of ^that file: #!/usr/bin/env python3
  • Make it executable with chmod +x
  • Add an empty file in my_package/scripts
  • Add this to CMakeLists:

To me, this seems easier than what the tutorial recommends with setup.cfg and but maybe I'm missing something. Perhaps it's not Windows-compatible or something like that.

edit flag offensive delete link more


Here it is said to also use the following command pointing to the directory where the scripts are located (this might be necessary only for certain ROS2 distributions) before using the install(PROGRAMS...) command: ament_python_install_package(my_package/scripts)

The making it executable step is really hard to notice. I had the same procedure from another site, but didn't make the python script executable. I could find the python script under install/my_pacakage/lib/my_pacakage/ but ros2 run my_pacakage would throw No executable found

aserbremen gravatar image aserbremen  ( 2023-02-24 09:16:29 -0600 )edit

Question Tools



Asked: 2018-08-01 04:26:03 -0600

Seen: 4,557 times

Last updated: Jan 26 '22