Ask Your Question

No such file or directory when using rosrun?

asked 2011-06-27 09:41:29 -0600

Sam Powers gravatar image

updated 2011-06-28 03:42:25 -0600

I'm running Diamondback on Maverick Meerkat Ubuntu. Basically the problem is that when I rosrun a particular node (, I just get a " ': [Errno 2] No such file or directory " error.

I can rosrun other files in the directory, so it's definitely in my package path. The permissions are set correctly (chmod +x worked). I have "#!/usr/bin/env python" at the top of my file. I ran it on a friend's computer (who also has ROS setup), and it threw the same error for him, so it wouldn't seem to be my Linux/python. Renaming it doesn't fix the problem. Commenting out the imports doesn't help. It's been "make"d many times now. All to no avail.

I can post the code if that would help, but it's rather long, and it's not even getting to the main (doesn't do a print).

Any ideas?

edit retag flag offensive close merge delete


Can you put your code on github or the like so that I can take a look at it?
mjcarroll gravatar imagemjcarroll ( 2011-06-27 12:16:56 -0600 )edit
Can you just run the node from the command line? rosrun is just a bash script which is like roscd PACKAGE && ./path_to_script Where it does some nice tab completion on executables.
tfoote gravatar imagetfoote ( 2011-06-27 17:46:40 -0600 )edit
Oh, yes, I should have mentioned that. I can do "python" and it runs fine. (EDIT: Actually, I need permission to post the code, so I have to get that first.)
Sam Powers gravatar imageSam Powers ( 2011-06-28 03:38:16 -0600 )edit
what happens when you execute: /usr/bin/env python?
dornhege gravatar imagedornhege ( 2011-06-29 11:40:23 -0600 )edit
When I run /usr/bin/env python: Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
Sam Powers gravatar imageSam Powers ( 2011-06-30 03:31:34 -0600 )edit
Can you put a minimal python script in the same location as the script in question. Just the #! and a printout. If that rosruns (what I'd expect) its some problem in your code.
dornhege gravatar imagedornhege ( 2011-06-30 03:35:49 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2011-06-30 08:25:34 -0600

Sam Powers gravatar image

My coworker figured out the answer. It was a DOS text file, not a UNIX text file. Converting it fixed the problem, and it was able to be rosrun.

I have no idea why it was a DOS text file, but at least it works now.

edit flag offensive delete link more


yea this happened to me, i wrote the file in windows pyscripter and i guess the encoding was different, re-writing the file worked

Sentinal_Bias gravatar imageSentinal_Bias ( 2013-03-11 16:01:07 -0600 )edit

To be precise, it is the line endings which create this problem. DOS/Windows '/r/n' do not work, only UNIX line endings '/n' work. Not the file encoding. You can probably change the line endings setting in your editors preferences or buffer options. If not, use another editor :)

Gullydwarf gravatar imageGullydwarf ( 2013-09-25 00:09:14 -0600 )edit

Fantastic! Even though this thread is dated, I was able to find it and solve this issue. Kudos! Searched for two days for a solution and this tip finally enabled a driver that was written in python.

b2256 gravatar imageb2256 ( 2016-02-05 00:16:24 -0600 )edit

answered 2011-06-29 11:03:05 -0600

tfoote gravatar image

you need to make executable.

chmod +x
edit flag offensive delete link more


I did that. Everyone who's looked at my problem has too. It doesn't help.
Sam Powers gravatar imageSam Powers ( 2011-06-30 02:54:54 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-06-27 09:41:29 -0600

Seen: 4,559 times

Last updated: Jun 30 '11