Active Topics

 


Reply
Thread Tools
Posts: 22 | Thanked: 0 times | Joined on Aug 2007
#1
How do you run .py files in maemo? Ive done a lot of google searching and i cant find anything helpful.
 
Posts: 21 | Thanked: 0 times | Joined on Aug 2007 @ Dresden, Germany
#2
Hello shortkid1101,

if you are familiar with xterm and happy to use it, you can just type there "python filename.py".
Also you can do "chmod u+x filename.py" to make your python file directly executable and put "#!/usr/bin/env python" as a first line, then you can run it as any executable just by typing its name.

If you like to run it from program menu, you have to create a desktop file for it. For this you need root access. The desktop file should be put for example here: /usr/share/applications/hildon/filename.desktop. The content should be like this:

[Dekstop Entry]
Version=0.0.1(enter the version)
Encoding=UTF-8
Name=MyName(enter the name)
Type=Application
Exec=path_to_filename.py(enter the path to your file, it should be made executable as described above)
Icon=icon_filename(enter the name of icon file)
X-Osso-Service=MyName(enter the name)
X-Osso-Type=application/x-executable

icon_filename should be a filename of PNG file with icon image without .png extention. This file should be put in /usr/share/pixmaps folder.

In principle you can prepare a .deb file to install a desktop file and all necessary stuff without root privileges via Applicaton Manager but this is another quite long story.

WBR

Alexib
__________________
Nokia 770 ITOS 2006
 
Posts: 22 | Thanked: 0 times | Joined on Aug 2007
#3
thanks a lot but when i type in python test.py it says "can't open file 'test.py': [errno 2] No such file or directory exists. I have tried the chmod u+x way and it says it doesn't exist also.
 
Posts: 21 | Thanked: 0 times | Joined on Aug 2007 @ Dresden, Germany
#4
Try to specify full path to test.py. If test.py is in your current folder, prepend ./ to it name.

alexib
__________________
Nokia 770 ITOS 2006
 
Posts: 22 | Thanked: 0 times | Joined on Aug 2007
#5
I have it in just the basic folder like when i click on the Nokia icon i see Audio clips, documents, test, ect.

This is a log from x term.
/ $ python
[Gcc 3.4.4 (release) (CodeSummary ARM 2005q3-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>>lybniz/lybniz.py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
does that mean that there is a problem with the script?
 
Posts: 21 | Thanked: 0 times | Joined on Aug 2007 @ Dresden, Germany
#6
No, you shouldn't try to run .py file from python interpreter. You should just type "python lybniz/lybniz.py" in the command prompt:
$ python lybniz/lybniz.py
and press Enter.
__________________
Nokia 770 ITOS 2006
 
Posts: 22 | Thanked: 0 times | Joined on Aug 2007
#7
when i type
/ $ python lybniz/lybniz.py
it says

python: can't open file 'lybniz/lybniz.py': [Errno 2] No such file or directory
 
Posts: 21 | Thanked: 0 times | Joined on Aug 2007 @ Dresden, Germany
#8
Then it means you specify wrong path to lybniz.py. What shows the following command?:
ls -l lybniz/lybniz.py
__________________
Nokia 770 ITOS 2006
 
Guest | Posts: n/a | Thanked: 0 times | Joined on
#9
Originally Posted by shortkid1101 View Post
I have it in just the basic folder like when i click on the Nokia icon i see Audio clips, documents, test, ect.
That's actually /home/user/MyDocs. To start a Python script in there, use:

Code:
~ $ python /home/user/MyDocs/test.py
When you start an X Terminal, its working directory is by default already set to /home/user (also called ~), and so this will work as well:

Code:
~ $ python MyDocs/test.py
 
Guest | Posts: n/a | Thanked: 0 times | Joined on
#10
Oh, and remember that you can use file name completion when typing file names. For example, typing "/home/user/MyDocs/test.py" can be shortened to:

Code:
/h<Tab><Tab>M<Tab>t<Tab>
I.e. type "/", "h", press Tab twice, type capital "M", press Tab, type "t" and press Tab. Tab is the button with two arrows pointing left and right on the upper left corner of the virtual keyboard (not present on the larger thumb keyboard). If there are more than one possible file name, pressing Tab will not complete the file name, but pressing Tab again lists the possible completions. Then it's just a matter of adding more letters and pressing Tab again.
 
Reply


 
Forum Jump


All times are GMT. The time now is 18:10.