[maemo-developers] [maemo-developers] python on maemo

From: Gustavo Sverzut Barbieri Gustavo.Barbieri at indt.org.br
Date: Tue May 9 21:47:22 EEST 2006
On Tuesday 09 May 2006 18:41, ext Christine Liu wrote:
> hi all -
>
> i'm following teemu's tutorial on python on the 770, part 1:
> http://www.teemuharju.net/2006/01/26/coding-for-nokia-770-using-python-part
>-1/
>
> so i'm running into issues with either run-standalone.sh + importing gtk
> and hildon packages. i installed pymaemo in normal matter and i am ssh'ing
> into my 770 through x11 on mac os x.
>
> i saved the sample code as uitest.py in /home/users.
>
> i typed
> Nokia770-13:/home/user# run-standalone.sh ./uitest.py
> ./uitest.py: 1: import: not found
> ./uitest.py: 2: import: not found
> ./uitest.py: 4: class: not found
> ./uitest.py: 6: Syntax error: "(" unexpected
>
> i made a helloworld.py (print "hello world") and did
> Nokia770-13:/home/user# run-standalone.sh ./helloworld.py
> ./helloworld.py: 1: print: not found
>
> strange - just following teemu's lead. so i'm not sure exactly how to use
> this run-standalone script.
>
> but if i run python directly, this works:
> Nokia770-13:/home/user# python2.4 helloworld.py
> hello world

That's because you miss the first line, a functional comment, to instruct 
system how to run your file. You should use as first line:

#!/var/lib/install/usr/bin/python2.4

That's if you use in real device, with Python installed from Application 
Installer. If you run "dpkg -i" on a scratchbox environment, use:

#!/usr/bin/python2.4


That's not about python, but about Unix standards. Perl, Tcl and others will 
behave the same way.


> anyway - *here's the main question* and most confusing. i go to python
> interactive environment...
> Nokia770-13:/home/user# python2.4
> Python 2.4.2 (#2, Jan 16 2006, 15:07:04)
> [GCC 3.3.4 (Debian)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>
> >>> import gtk
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/home/ruda/pymaemo2/pool/main/p/python-gtk2/python-gtk2-2.6.1
> /debian/tmp/usr/lib/python2.4/site-packages/gtk-2.0/gtk/__init__.py", line
> 37, in ?
> RuntimeError: could not open display
>
> >>> import hildon
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> ImportError: could not import gtk._gtk
>
> how do i best remedy this? shouldnt these modules be included in pymaemo?
> i'm not familiar with how to deal with these kinds of errors. thanks much
> for your help.

You should launch a Xephyr or Xnest, as explained in tutorial 
(http://maemo.org/platform/docs/tutorials/Maemo_tutorial.html#Installing-Xephyr)

then you should export DISPLAY=:2 (if you use tutorial script).

I  have a library to help maemo development, it's called Eagle, please check 
it out in http://www.gustavobarbieri.com.br/eagle and 
http://www.gustavobarbieri.com.br/eagle/docs/   It's done using PyGTK, but 
you don't have all problems PyGTK exposes... in other words, it's simple to 
use.


-- 
Gustavo Sverzut Barbieri
------------------------
INdT, Recife, Brazil

Jabber: barbieri at gmail.com
   MSN: barbieri at gmail.com
  ICQ#: 17249123
 Skype: gsbarbieri
Mobile: +55 (81) 9927 0010
 Phone:  +1 (347) 624 6296; 08122692 at sip.stanaphone.com
   GPG: 0xB640E1A2 @ wwwkeys.pgp.net

More information about the maemo-developers mailing list