Reply
Thread Tools
Munk's Avatar
Posts: 229 | Thanked: 108 times | Joined on Oct 2007 @ Sacramento, California
#1
I've done 20 minutes of searching and believe that it was a good effort.

My question:
I did some VERY EASY development on my Windows machine with Python 2.5 installed along with PyGame 1.7. I copied my program called "time.py" over to my NIT expecting it to work there since it really is a simple program and it was copied from another NIT Python app.

On my NIT, I have been running other peoples Python scripts from:
/home/user/py

The script originally came from one already working on my NIT. I didn't change any of the imports at the beginning and the script begins with:
#!/usr/bin/python

I first used:
chmod +x time.py

But when I try to run it with ./time.py it says:
/bin/sh: ./time.py: not found

What am I not understanding here? Is this more that a file needs to be in a specific place? Is it that a Windows file has different privileges and I need to set it on Linux? I tried compiling it by running:
python -OO time.py

but it too says it cannot find the file. I know that PluThon exists but I really think this should work without installing more stuff.

Help.
 
Posts: 1,101 | Thanked: 1,184 times | Joined on Aug 2008 @ Spain
#2
/bin/sh: ./time.py: not found
That means that the shell don't find your program in the current directory, or that the python executable can't be found
If your file is there and python works then the "#!/usr/bin/python" must be wrong.
Since you have copied the file from a windows machine, the file will have DOS end of lines (0xd 0xa). Since in linux the eol is 0xA the 0xD character gets appended to the #! line and will cause the interpreter search fail.
You should first run the program through an utility like dos2unix or open it with a text editor able to save it with the right eol (PyGTKEditor for example)
 

The Following 4 Users Say Thank You to maacruz For This Useful Post:
Munk's Avatar
Posts: 229 | Thanked: 108 times | Joined on Oct 2007 @ Sacramento, California
#3
Ooh, maacruz, I like what you are saying as it seems to make sense. I have used nano to edit this file on the NIT but it still doesn't seem to change anything. I'll try looking at the other items you mentioned when I get home later tonight.

Thanks for you advice and any other suggestions would be great.
 
Munk's Avatar
Posts: 229 | Thanked: 108 times | Joined on Oct 2007 @ Sacramento, California
#4
maacruz,

YOU WERE RIGHT! It was the file being odd to Linux/Python. Using Geany, I copied all the lines of code into a new file, and when I ran it, it worked perfectly the first time. I thought I was going crazy because it should have worked.

Thank you for your insight and help.
 
Nyrath's Avatar
Posts: 92 | Thanked: 50 times | Joined on Jan 2006 @ the praeternatural tower
#5
Yes, the difference between DOS end-of-line and Linux end-of-line is an annoying problem, and still trips me up occasionally.
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#6
something like this in VI should fix the newline problem..

:%s/\r//g

or

:%s/^V^M//g

That's Control+V, Control+M

one of these should kill the microsoft newline junk.
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 
Posts: 18 | Thanked: 1 time | Joined on Jul 2008
#7
hi, i am having a bit of trouble myself.. i write the souce code.. save it.. then when i push the run button it opens a terminal and says "press enter" then anything i press closes the window.. i am trying to program straight in the n810 using pyGTKEditor by khertan.. thanks for the help..
 
bongo's Avatar
Posts: 291 | Thanked: 124 times | Joined on Feb 2006 @ Trier, Germany
#8
Originally Posted by renanholanda View Post
hi, i am having a bit of trouble myself.. i write the souce code.. save it.. then when i push the run button it opens a terminal and says "press enter" then anything i press closes the window.. i am trying to program straight in the n810 using pyGTKEditor by khertan.. thanks for the help..
This happens when your application has no output. Insert a print command and you'll see it in the terminal window.
__________________
ongo bongo!
 
Posts: 18 | Thanked: 1 time | Joined on Jul 2008
#9
thanks for the help.. but even with print comands or raw_input().. nothing comes up.. just goes 'press enter to continue' its like something is going wrong with the program itself.. it was working fine before i flashed the device.. but I installed the same way.. dont know why it would be any different this time.. maybe its not running python.. maybe the installer did not set the path straight.. or put the program on the wrong folder.. don't know.. any other thoughts??
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#10
If you have python-launcher installed, you won't see the output. Try running with 'python <.py file>' manually.
 
Reply

Tags
help with python please

Thread Tools

 
Forum Jump


All times are GMT. The time now is 04:21.