Robotics StackExchange | Archived questions

Windows10 rosrun couldn't find python scripts in path scripts.

I have run setup.bat

Such I have a package in root path named "testpkg", and my python scripts in path testpkg\scripts\talker.py

If I run rosrun test_pkg talker.py in cmd, I will got error "Couldn't find executable named talker.py"

Buf if I run rosrun test_pkg scripts\talker.py, it will work well.

It's a little inconvenient, could anyone tell me how to fix it? Thanks.

Asked by 张庆昊 on 2019-06-17 23:44:04 UTC

Comments

Have you installed your Python script in your CMakeLists.txt file (search for catkin_install_python())? http://docs.ros.org/melodic/api/catkin/html/howto/format2/installing_python.html

Asked by Sean Yen on 2019-06-18 01:36:28 UTC

@Sean Yen Can you give me some examples? I tried to add catkin_install_python(PROGRAMS test_pkg scripts/talker.py DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) in my CMakeLists.txt in path "test_pkg\". But I got error. I think I write it with wrong format. So. could you give some examples? Thanks a lot!.

Asked by 张庆昊 on 2019-06-19 04:35:33 UTC

Can you share the error message you see? Most likely I would guess you should change the line to catkin_install_python(PROGRAMS scripts/talker.py DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) and then run catkin_make again.

Asked by Sean Yen on 2019-06-19 15:16:43 UTC

@Sean Yen catkin_python_setup() called with unused arguments: PROGRAMS;scripts/talker.py;DESTINATION

Asked by 张庆昊 on 2019-06-19 20:13:13 UTC

My computer couldn't connent network, so I just type the main error message of the log, if you want to the whole log, I can take pictures for you. I'm sorry about that.

Asked by 张庆昊 on 2019-06-19 20:19:38 UTC

@张庆昊 I am also new to ROS but outgoing from the error message i would suggest that you add the python scripts to catkin_install_python(...) and not to catkin_python_setup() in CMakeList.txt so it looks like this:

# catkin_python_setup()

catkin_install_python(PROGRAMS
  scripts/talker.py
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

Afterwards you should try to build it again with catkin_make.

Asked by mab0189 on 2021-02-09 08:00:35 UTC

@mab0189 Thanks, but I have left my last company, and start a new career. For all that, still thanks for you.

Asked by 张庆昊 on 2021-02-09 22:44:50 UTC

Answers