×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    39

    How to import my own modules

    Hi,
    my application is composed by 3 files

    1. default.py
    2. lib1.py
    3. lib2.py


    I put all 3 files in a folder, then I have created the SIS file with PyS60 Application Packager.

    After installation, when I run the application on the phone I get
    Code:
    ImportError: No module named lib1.py
    Help please!!!

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

    Re: How to import my own modules

    Did you appended the path where lib1 and lib2 were dropped on the phone, by the sis?

    sys.path.append?
    Pankaj Nathani
    www.croozeus.com

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    125

    Re: How to import my own modules

    Quote Originally Posted by launch View Post
    After installation, when I run the application on the phone I get
    Code:
    ImportError: No module named lib1.py
    Put this at the top of the default.py script...

    Code:
    import sys, os
    try:
        raise Exception
    except Exception:
        mydir = os.path.dirname(sys.exc_info()[2].tb_frame.f_code.co_filename)
    if not mydir:
        mydir = os.getcwd()
    sys.path.append(mydir)
    Should work in all cases.

  4. #4
    Nokia Developer Expert
    Join Date
    Apr 2007
    Posts
    131

    Re: How to import my own modules

    Quote Originally Posted by launch View Post
    Hi,
    my application is composed by 3 files

    1. default.py
    2. lib1.py
    3. lib2.py


    I put all 3 files in a folder, then I have created the SIS file with PyS60 Application Packager.

    After installation, when I run the application on the phone I get
    Code:
    ImportError: No module named lib1.py
    Help please!!!
    For now you have to package all the lib files in a directory and append this to sys.path before import'ing them

    1. default.py
    2. lib\lib1.py
    3. lib\lib2.py


    import sys
    sys.path.append('c:\\private\\<UID>\\lib')

    import lib1, lib2

    :IMPORTANT NOTE:
    This is because of a limitation in one of the OpenC APIs. The import mechanism will be fixed in the next release of PyS60 and you dont have to do the above mentioned trick then.
    Last edited by mahesh.sayibabu; 2009-04-21 at 08:07.

  5. #5
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: How to import my own modules

    Quote Originally Posted by mahesh.sayibabu View Post
    This is because of a bug in one of the OpenC APIs. The import mechanism will be fixed in the next release of PyS60 and you dont have to do the above mentioned trick then.
    Been secretly hoping for this

    --jouni counting the few remaining days for next release

  6. #6
    Regular Contributor
    Join Date
    Oct 2007
    Posts
    114

    Re: How to import my own modules

    Quote Originally Posted by JOM View Post

    --jouni counting the few remaining days for next release
    Oh noes! Our secret is out!
    import antigravity

  7. #7
    Nokia Developer Expert
    Join Date
    Apr 2007
    Posts
    131

    Re: How to import my own modules

    Hope you have tested with PyS60 1.9.4 Application Packager, this short comming is fixed with this release.

  8. #8
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643

    Re: How to import my own modules

    Quote Originally Posted by launch View Post
    After installation, when I run the application on the phone I get
    Code:
    ImportError: No module named lib1.py
    Sounds like you have "import lib1.py" in your script when you should have "import lib1"...

Similar Threads

  1. GoogleIt
    By deepika.mangla in forum Symbian
    Replies: 5
    Last Post: 2011-05-28, 11:04
  2. JXME + OSGi for j2me
    By gittu in forum Mobile Java General
    Replies: 13
    Last Post: 2009-03-04, 09:34
  3. bluetooth setting using bluecove
    By amoon108 in forum Bluetooth Technology
    Replies: 0
    Last Post: 2008-10-15, 10:11
  4. problem on running my application
    By rsf in forum Symbian
    Replies: 7
    Last Post: 2007-10-21, 15:56
  5. SocketConnection Work on 6600&Emulators BUT NOT IN 6680
    By eerant in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2006-03-11, 00:35

Posting Permissions

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