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

ROS Melodic no longer finding python scripts

asked 2022-08-01 14:06:05 -0500

vbplaya gravatar image

NOTE: Working in Windows (I have to because this is the machine that my work requires me to use).

I’m creating a project which will communicate with another companies ROS project. Originally, I was building it in Noetic (which was also on this same windows machine) but I was told they are using Melodic so I have to revert back to Melodic on mine. When I was running my packages in Noetic it ran fine … I used the following command:

rosrun gui_pkg

However, when I changed over to Melodic for some reason it no longer can find the so in order to run it, I need to run the following command:

rosrun gui_pkg scripts/

That’s not a big deal but I am now running into errors finding other custom libraries. For example, the following import no longer works:

from gui_templates.tx_rx_display import TxRxDisplay

Any ideas of why this is now an issue? Btw, I also have the very simple package from the ROS website that worked completely fine in Noetic but requires the "scripts/" in the rosrun command in order to run as well.

Some relevant info:

OS: Windows 10

folder layout under gui_pkg folder

  • CMakeLists.txt
  • package.xml
  • scripts
    • gui_templates


 from distutils.core import setup
 from catkin_pkg.python_setup import generate_distutils_setup

 d = generate_distutils_setup(
     package_dir={‘’: ‘scripts’}
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2022-08-01 19:03:32 -0500

vbplaya gravatar image

BLUF: Melodic uses Python 2 which requires a file in each folder containing python scripts.

I found out what the issue is. Melodic uses Python 2 by default and Noetic uses Python 3 by default. I have only worked in Python 3 and didn't know that if I want to import a python file from a folder that you must include a file in that folder (even if it is empty).

So to get it to work I just had to put a file into the gui_templates folder, run catkin_make, source devel\setup.bat ... and then it worked. I still need to type in: rosrun gui_pkg scripts/ but now if finds all the other python files.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2022-08-01 14:06:05 -0500

Seen: 51 times

Last updated: Aug 01 '22