You Are Here:

Community: Developer Discussion Boards

#1 Old How to import my own modules - 2009-04-17, 14:37

Join Date: Apr 2007
Posts: 39
launch
Offline
Registered User
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!!!
Reply With Quote

#2 Old Re: How to import my own modules - 2009-04-17, 14:55

Join Date: May 2007
Posts: 2,738
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Did you appended the path where lib1 and lib2 were dropped on the phone, by the sis?

sys.path.append?
Reply With Quote

#3 Old Re: How to import my own modules - 2009-04-17, 18:58

Join Date: Mar 2003
Posts: 125
Location: UK
aya42
Offline
Regular Contributor
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.
Reply With Quote

#4 Old Re: How to import my own modules - 2009-04-21, 07:14

Join Date: Apr 2007
Posts: 131
mahesh.sayibabu's Avatar
mahesh.sayibabu
Offline
Regular Contributor
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 09:07.
Reply With Quote

#5 Old Re: How to import my own modules - 2009-04-21, 07:35

Join Date: Mar 2003
Posts: 937
Location: Espoo, Finland
JOM's Avatar
JOM
Offline
Forum Nokia Champion
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
Reply With Quote

#6 Old Re: How to import my own modules - 2009-04-21, 08:10

Join Date: Oct 2007
Posts: 114
ashwinurao
Offline
Regular Contributor
Quote:
Originally Posted by JOM View Post

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


import antigravity
Reply With Quote

#7 Old Re: How to import my own modules - 2009-05-11, 13:29

Join Date: Apr 2007
Posts: 131
mahesh.sayibabu's Avatar
mahesh.sayibabu
Offline
Regular Contributor
Hope you have tested with PyS60 1.9.4 Application Packager, this short comming is fixed with this release.
Reply With Quote

#8 Old Re: How to import my own modules - 2009-05-12, 10:28

Join Date: Dec 2004
Posts: 646
jplauril's Avatar
jplauril
Offline
Forum Nokia Expert
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"...
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
JXME + OSGi for j2me gittu Mobile Java General 13 2009-03-04 10:34
bluetooth setting using bluecove amoon108 Bluetooth Technology 0 2008-10-15 11:11
problem on running my application rsf Python 7 2007-10-21 16:56
GoogleIt deepika.mangla General Symbian C++ 4 2007-01-08 02:07
SocketConnection Work on 6600&Emulators BUT NOT IN 6680 eerant Mobile Java Networking & Messaging & Security 4 2006-03-11 01:35

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia