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

asked 2019-06-17 23:52:04 -0600

张庆昊 gravatar image

I have run setup.bat

Such I have a package in root path named "test_pkg", and my python scripts in path test_pkg\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.

edit retag flag offensive close merge delete

Comments

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

Sean Yen gravatar image Sean Yen  ( 2019-06-18 01:36:28 -0600 )edit

@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!.

张庆昊 gravatar image 张庆昊  ( 2019-06-19 04:35:33 -0600 )edit

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.

Sean Yen gravatar image Sean Yen  ( 2019-06-19 15:16:43 -0600 )edit

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

张庆昊 gravatar image 张庆昊  ( 2019-06-19 20:13:13 -0600 )edit

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.

张庆昊 gravatar image 张庆昊  ( 2019-06-19 20:19:38 -0600 )edit

@张庆昊 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.

mab0189 gravatar image mab0189  ( 2021-02-09 07:00:35 -0600 )edit
1

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

张庆昊 gravatar image 张庆昊  ( 2021-02-09 21:44:50 -0600 )edit