×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    21

    how can I extend default python library ?

    How can I extend default python library ? I installed pys60 in my mobile phone, but I must extend my own python libraries on the default library so that I can import my own module when using mod_python with mobile web server... how should I do ? Thanks!

  2. #2
    Regular Contributor
    Join Date
    Oct 2007
    Posts
    67

    Re: how can I extend default python library ?

    Pure python modules can be installed in any directory on sys.path (mod_python implements an Apache directive PythonPath allowing you to set it).

    Python extensions implemented in C are technically dll files and thus need to be installed into \sys\bin using the symbian software installer on 3rd edition.

  3. #3
    Super Contributor
    Join Date
    May 2006
    Location
    Oulu, Finland
    Posts
    622

    Re: how can I extend default python library ?

    The default installation folders for the Python libs (.py, .pyc) are C:\\resource, E:\\resource and E:\\python\\lib. The last one has the advantage to be easily accessible via USB or bluetooth.

    The Python DLLs (.pyd) have to be in C:\\sys\\bin or E:\\sys\\bin.

    As a general case it is strongly adviced to install the libraries on the C:\\ drive (as well as PyS60) to avoid any problems with library import and standalone applications. E:\\python\\lib gives more flexibility since you can easily push the files inside. So I would say that it makes life easier for debugging but as soon as your library is ready, make a proper installation package.

    LFD
    Devices:
    Nokia E61 3rd Edition - pys60 1.4.0

    Tips and modules:
    http://www.lfdm.net/thesis

  4. #4
    Registered User
    Join Date
    Oct 2007
    Posts
    21

    Re: how can I extend default python library ?

    Quote Originally Posted by lfd View Post
    The default installation folders for the Python libs (.py, .pyc) are C:\\resource, E:\\resource and E:\\python\\lib. The last one has the advantage to be easily accessible via USB or bluetooth.

    The Python DLLs (.pyd) have to be in C:\\sys\\bin or E:\\sys\\bin.

    As a general case it is strongly adviced to install the libraries on the C:\\ drive (as well as PyS60) to avoid any problems with library import and standalone applications. E:\\python\\lib gives more flexibility since you can easily push the files inside. So I would say that it makes life easier for debugging but as soon as your library is ready, make a proper installation package.

    LFD
    HI, LFD, thanks for your reply. I have made an installation package and installed it on my mobile phone, but I cannot import any of the modules in this library, what's the problem here ? Thank you very much !

  5. #5
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,800

    Re: how can I extend default python library ?

    Quote Originally Posted by lb213_2000 View Post
    HI, LFD, thanks for your reply. I have made an installation package and installed it on my mobile phone, but I cannot import any of the modules in this library, what's the problem here ? Thank you very much !
    Hello lb213_2000

    Where did you push the lib files(.pyd files)? As LFD said did you put them in E:\\python\\libs ?
    Moreover which modules do youtry to import and what is the error that youare facing?

    Best Regards
    croozeus
    Pankaj Nathani
    www.croozeus.com

  6. #6
    Registered User
    Join Date
    Oct 2007
    Posts
    21

    Re: how can I extend default python library ?

    Quote Originally Posted by croozeus View Post
    Hello lb213_2000

    Where did you push the lib files(.pyd files)? As LFD said did you put them in E:\\python\\libs ?
    Moreover which modules do youtry to import and what is the error that youare facing?

    Best Regards
    croozeus
    hello, croozeus, I forgot to say that my lib files are written in python, all of these files are some directories including .py files, not C++ written files, so how should I install these modules properly so that I can import any of these modules ?? Thanks a lot.

  7. #7
    Regular Contributor
    Join Date
    Oct 2007
    Posts
    67

    Re: how can I extend default python library ?

    Quote Originally Posted by lb213_2000 View Post
    hello, croozeus, I forgot to say that my lib files are written in python, all of these files are some directories including .py files, not C++ written files, so how should I install these modules properly so that I can import any of these modules ?? Thanks a lot.
    For a 3rd edition device:

    When installing to the E: drive (memory card) the correct path is E:\python\lib (not libs). If it doesn't exist you can simply create it and restart the python shell. Open a console and check the the variable sys.path to make sure it works as expected:

    Code:
    >>> import sys
    >>> sys.path
    ['E:\\private\\2000b1a5', 'c:\\resource', 'e:\\python\\lib']
    >>>
    When your library is finished, tested and found to work correctly, it is a good idea to create an installation package to install it to c:\resource. Before that, put it into e:\python\lib because it is much easier to access and modify there.

  8. #8
    Registered User
    Join Date
    Oct 2007
    Posts
    21

    Re: how can I extend default python library ?

    Quote Originally Posted by nlsp View Post
    For a 3rd edition device:

    When installing to the E: drive (memory card) the correct path is E:\python\lib (not libs). If it doesn't exist you can simply create it and restart the python shell. Open a console and check the the variable sys.path to make sure it works as expected:

    Code:
    >>> import sys
    >>> sys.path
    ['E:\\private\\2000b1a5', 'c:\\resource', 'e:\\python\\lib']
    >>>
    When your library is finished, tested and found to work correctly, it is a good idea to create an installation package to install it to c:\resource. Before that, put it into e:\python\lib because it is much easier to access and modify there.
    What I am doing is to develop a python written soap library on my mobile phone, I have created python\lib in E:, it seems that python files under E:\\python can import modules of this library, but mod_python(a plug-in in mobile web server) can not import this module, so I think this library must be installed in C:\resource so that mod_python can find it.
    I'm a new one in making installation package, and have tried some times using ensymble to make a sis package, but after installing this generated package on my phone, even python files under E:\\python can not import this module...
    so how can I make a sis package correctly so that it can be installed in c:\\resource ?? Thanks a lot !

  9. #9
    Registered User
    Join Date
    Oct 2007
    Posts
    21

    Re: how can I extend default python library ?

    my soap library include files and directories...

  10. #10
    Super Contributor
    Join Date
    May 2006
    Location
    Oulu, Finland
    Posts
    622

    Re: how can I extend default python library ?

    Good morning lb213_2000!

    Few more things for you to check

    The following lines have been added to the shell's default.py but it is not by default! Add the few line bellow at the very beginning of your script to see if it helps:
    Code:
    import os.path, sys
    for path in ('c:\\python\\lib','e:\\python\\lib'):
        if os.path.exists(path):
            sys.path.append(path)
    You can use simplesis directive of ensymble to make the installation packages: in a trysis directory put the file as

    Code:
    trysis
        |
        + resource
            |
            + your files + folder +subfolders...
    then

    Code:
    python ensymble simplesis trysis

    PyS60 and all your libraries have to be install under C: directory to avoid problem with imports.

    Let see if that helps.

    LFD
    Devices:
    Nokia E61 3rd Edition - pys60 1.4.0

    Tips and modules:
    http://www.lfdm.net/thesis

  11. #11
    Registered User
    Join Date
    Oct 2007
    Posts
    21

    Re: how can I extend default python library ?

    Quote Originally Posted by lfd View Post
    Good morning lb213_2000!

    Few more things for you to check

    The following lines have been added to the shell's default.py but it is not by default! Add the few line bellow at the very beginning of your script to see if it helps:
    Code:
    import os.path, sys
    for path in ('c:\\python\\lib','e:\\python\\lib'):
        if os.path.exists(path):
            sys.path.append(path)
    You can use simplesis directive of ensymble to make the installation packages: in a trysis directory put the file as

    Code:
    trysis
        |
        + resource
            |
            + your files + folder +subfolders...
    then

    Code:
    python ensymble simplesis trysis

    PyS60 and all your libraries have to be install under C: directory to avoid problem with imports.

    Let see if that helps.

    LFD
    Thanks, lfd, with your help, I hava installed my package in c:\\resource successfully. However, I met another annoying problem, which is:
    Code:
    import e32
    
    if e32.s60_version_info>=(3,0):
        import imp
        _pyexpat=imp.load_dynamic('_pyexpat', 'c:\\sys\\bin\\_pyexpat.pyd')
        del imp
    else:
        import _pyexpat
    
    del e32
    from _pyexpat import *
    del _pyexpat
    problem is
    Code:
    _pyexpat=imp.load_dynamic('_pyexpat', 'c:\\sys\\bin\\_pyexpat.pyd')
    _pyexpat.pyd must be installed in c:\sys\bin directory, but c:\sys directory is inaccessible. I have tried to put _pyexpat.pyd somewhere else, such as c:\resource and change the path in code to "c:\\resource\\_pyexpat.pyd", but it will give me the error :
    SymbianError: [Errno -1] KErrNotFound,
    so is it possible to put this _pyexpat.pyd in c:\sys\bin or anywhere else so that system can find this pyd file, thanks a lot !

  12. #12
    Registered User
    Join Date
    Oct 2007
    Posts
    21

    Re: how can I extend default python library ?

    so why I can not install the generated sis file ? my directory structure is:
    trysis
    |
    +--resource
    +--sys
    |
    |--bin
    |
    |--_pyexpat.pyd
    then,
    python ensymble.py simplesis trysis,
    trysis generated, but when I tried to install this sis file, symbian gave me the error: "cannot install", I think the problem is the .pyd file, because if I make a stand-alone sis file for the .pyd file and tried to install it, it failed too, what's the reason here ? Thanks!
    Last edited by lb213_2000; 2007-11-08 at 12:30. Reason: wrong word

  13. #13
    Regular Contributor
    Join Date
    Oct 2007
    Posts
    67

    Re: how can I extend default python library ?

    Earlier in this thread, you said your library is written in python and contains only .py files. For _expat.pyd this is certainly not true.

    Where does the _expat.pyd file come from? Is it compiled and linked against Python for S60?

  14. #14
    Registered User
    Join Date
    Oct 2007
    Posts
    21

    Re: how can I extend default python library ?

    Quote Originally Posted by nlsp View Post
    Earlier in this thread, you said your library is written in python and contains only .py files. For _expat.pyd this is certainly not true.

    Where does the _expat.pyd file come from? Is it compiled and linked against Python for S60?
    I'm sorry for not mention that earlier, actually, this _pyexpat.pyd is a part of PyXml used for parsing xml files, so I have to install this file in the phone together with my library files. I have tested the library file in 3rd Edition emulator and it works fine, then I met these problems during generated sis file installation. Thanks.

  15. #15
    Regular Contributor
    Join Date
    Oct 2007
    Posts
    67

    Re: how can I extend default python library ?

    Interesting!

    Did you check out http://wiki.forum.nokia.com/index.php/How_to_use_XML and http://www.saunalahti.fi/~tsharju/pys60/ ??

    If you get it running please report back :-)

    Thanks

    Niels

Similar Threads

  1. GoogleIt
    By deepika.mangla in forum Symbian
    Replies: 5
    Last Post: 2011-05-28, 11:04
  2. Fail to build syexpat 1.3 under 2nd FP3
    By harry_zhang in forum Symbian
    Replies: 10
    Last Post: 2010-03-19, 10:24
  3. SyExpat + problem + memmove + Carbide Express
    By pearman in forum Symbian
    Replies: 2
    Last Post: 2006-10-14, 22:21
  4. Compilation series 60 3rd edition
    By asmobease in forum Symbian Tools & SDKs
    Replies: 32
    Last Post: 2006-09-13, 09:46
  5. Can’t launch application on 6630
    By kaffemannen in forum Symbian
    Replies: 8
    Last Post: 2005-06-29, 10:49

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×