0
$\begingroup$

Rosanswers logo

I'm running Diamondback on Maverick Meerkat Ubuntu. Basically the problem is that when I rosrun a particular node (State_Machine.py), 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?


Originally posted by Sam Powers on ROS Answers with karma: 116 on 2011-06-27

Post score: 4


Original comments

Comment by dornhege on 2011-06-30:
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.

Comment by Sam Powers on 2011-06-30:
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.

Comment by dornhege on 2011-06-29:
what happens when you execute: /usr/bin/env python?

Comment by Sam Powers on 2011-06-28:
Oh, yes, I should have mentioned that. I can do "python State_Machine.py" and it runs fine. (EDIT: Actually, I need permission to post the code, so I have to get that first.)

Comment by tfoote on 2011-06-27:
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.

Comment by mjcarroll on 2011-06-27:
Can you put your code on github or the like so that I can take a look at it?

Comment by Tatsat on 2021-04-08:
Hello, this is not working for me. C++ files work without problem. Issue is only with python files. I made the file executable with chmod +x talker.py .....(I am a beginner), added the #!/usr/bin/env python in the file, and also converted from DOS to UNIX. It still does not work for me. It specifically cannot find python files. ERROR : /usr/bin/env: ‘python’: No such file or directory ...... I am using ROS Noetic, and VS Code platform.

Comment by Tatsat on 2021-04-08:
So, the problem got solved. I ran: sudo apt-get install python-is-python3 ....I cannot figure out how it got figured out. It had something to do with installation of python 3. I installed ROS Noetic but I did not specifically installed Python 3. So maybe the problem was there..LOL. BTW thanks to this link: https://askubuntu.com/questions/942930/usr-bin-env-python-no-such-file-or-directory I found the answer

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

you need to make State_Machine.py executable.

chmod +x State_Machine.py

Originally posted by tfoote with karma: 58457 on 2011-06-29

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by Sam Powers on 2011-06-30:
I did that. Everyone who's looked at my problem has too. It doesn't help.

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by Sam Powers with karma: 116 on 2011-06-30

This answer was ACCEPTED on the original site

Post score: 6


Original comments

Comment by Sentinal_Bias on 2013-03-11:
yea this happened to me, i wrote the file in windows pyscripter and i guess the encoding was different, re-writing the file worked

Comment by Gullydwarf on 2013-09-25:
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 :)

Comment by b2256 on 2016-02-05:
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. http://www.cyberciti.biz/faq/howto-unix-linux-convert-dos-newlines-cr-lf-unix-text-format/

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.