You Are Here:

Community: Developer Discussion Boards

#1 Old modules do not get load on 6120c - 2009-01-22, 18:24

Join Date: Jan 2009
Posts: 2
pythonmax
Offline
Registered User
Hello together,

I've started developing with pyS60 (Version 1.4.5 final) on my Nokia 6120 classic and everything works fine so far - except that I'm not able to load any external modules.
I need the csv module (http://docs.python.org/library/csv.html) and put the csv.py from my local Python installation (Ubuntu 8.10) into my Python Script folder on my mobile (E:\\Python) on the external memory card.

Then I start the interactive console on my phone and I get
>>> import csv
>>> Import Error: No module named csv

Same happens when I put a simple python file with "import csv" in the script folder (E:\\Python) and start the script from within Python.

Could anybody help me?

Thanks a lot!
Reply With Quote

#2 Old Re: modules do not get load on 6120c - 2009-01-22, 18:49

Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Send a message via Skype™ to Rafael T.
Rafael T.'s Avatar
Rafael T.
Offline
Forum Nokia Champion
Quote:
Originally Posted by pythonmax View Post
Hello together,

I've started developing with pyS60 (Version 1.4.5 final) on my Nokia 6120 classic and everything works fine so far - except that I'm not able to load any external modules.
I need the csv module (http://docs.python.org/library/csv.html) and put the csv.py from my local Python installation (Ubuntu 8.10) into my Python Script folder on my mobile (E:\\Python) on the external memory card.

Then I start the interactive console on my phone and I get
>>> import csv
>>> Import Error: No module named csv

Same happens when I put a simple python file with "import csv" in the script folder (E:\\Python) and start the script from within Python.

Could anybody help me?

Thanks a lot!
You need to tell python the directory of the file you want to import:

Code:
import sys

sys.path.append('E:\\Python')

import csv
Hope it helps,

Rafael.
Reply With Quote

#3 Old Re: modules do not get load on 6120c - 2009-01-22, 20:40

Join Date: Nov 2007
Posts: 314
Location: Sertaozinho/Brazil
Send a message via MSN to marcelobarrosalmeida Send a message via Skype™ to marcelobarrosalmeida
marcelobarrosalmeida's Avatar
marcelobarrosalmeida
Offline
Forum Nokia Champion
Python is prepared to look for scripts in e:\python\lib, besides other directories in C: (private\<id>, resource).
If you want to put it in e:\python, follow Rafael instructions.

My strategy is to put my scripts wherever I want and add an entry point in e:\python.

e:\python\myprogentry.py:
Code:
import sys
sys.path.append('e:\\mydir\\')
import mymodule

mymodule.run() # put your initialization code here
This way, I do not need to add a sys.path.append() call inside my scripts.


Marcelo Barros
Nokia E71, N800, N95 and XM 5800
http://www.croozeus.com
http://wordmobi.wordpress.com
http://jedizone.wordpress.com
Reply With Quote

#4 Old Re: modules do not get load on 6120c - 2009-01-23, 13:27

Join Date: Mar 2003
Posts: 936
Location: Espoo, Finland
JOM's Avatar
JOM
Offline
Forum Nokia Champion
Quote:
Originally Posted by marcelobarrosalmeida View Post
My strategy is to put my scripts wherever I want and add an entry point in e:\python.

e:\python\myprogentry.py:
Code:
import sys
sys.path.append('e:\\mydir\\')
import mymodule

mymodule.run() # put your initialization code here
This way, I do not need to add a sys.path.append() call inside my scripts.
You force user to install your script/app on e-drive Not very nice... Then you also have to remember to force SIS installation only on e-drive!

On the other hand you could try to find out what is "current" directory or drive and just add that. Or an easier way might be to add both c and e drives on sys.path:

Code:
import sys
sys.path.append('c:\\mydir\\')
sys.path.append('e:\\mydir\\')
import mymodule

mymodule.run() # put your initialization code here
Cheers,

--jouni who wants to have TOTAL CONTROL over HIS OWN phone
Reply With Quote

#5 Old Re: modules do not get load on 6120c - 2009-01-23, 20:02

Join Date: Jan 2009
Posts: 2
pythonmax
Offline
Registered User
Quote:
Originally Posted by Rafael T. View Post
Hope it helps,

Rafael.
Hi Rafael,

thanks a lot, you took me one step further.

But now I get the error:

Code:
no module named _csv
In csv.py line 7 states
Code:
from _csv import Error, .....
I found a _csv.so in my local python installation (under /usr/lib/python2.5/lib-dynload"), but it doesn't help to put it in E:\Python on my phone.

Any hints for me?

Thanks!
Reply With Quote

#6 Old Re: modules do not get load on 6120c - 2009-01-23, 20:17

Join Date: Nov 2007
Posts: 314
Location: Sertaozinho/Brazil
Send a message via MSN to marcelobarrosalmeida Send a message via Skype™ to marcelobarrosalmeida
marcelobarrosalmeida's Avatar
marcelobarrosalmeida
Offline
Forum Nokia Champion
[quote=JOM;533648]You force user to install your script/app on e-drive Not very nice... Then you also have to remember to force SIS installation only on e-drive!
[/code]
No, that is not my point !
In fact, my code is free of any sys.path.append(). This is nice way for generating and testing .sis, without even testing if you are in emulator or not. That stub code is just for starting my application and it is not included in the application itself. When installed, the sys.path.append() is not necessary since all .py files will be together. However, if I am running scripts from memory card (not a sis), the stub code do the dirt job and add a call to append().


Marcelo Barros
Nokia E71, N800, N95 and XM 5800
http://www.croozeus.com
http://wordmobi.wordpress.com
http://jedizone.wordpress.com
Reply With Quote

#7 Old Re: modules do not get load on 6120c - 2009-01-23, 21:40

Join Date: Mar 2003
Posts: 936
Location: Espoo, Finland
JOM's Avatar
JOM
Offline
Forum Nokia Champion
Hi,

No problem, I use something similar: have just-in-case code in default.py regardless whether I need it or not Glad to hear you prefer sw which can be installed anywhere! Hopefully PyS60 2.x will also support that.. 1.4.x has some mysterious bugs which require occasionally installation on exactly same drive as python runtime and maybe even on c-drive. Not clear why, but that's the way things are.

Cheers,

--jouni
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
Nokia 6120c (S60 v3 v3.70) - J2ME app running from memory card works first then fails mmcnamee Mobile Java General 6 2008-08-07 11:31
Grid app is crashing... need urgent help... shankha General Symbian C++ 4 2007-11-20 12:52
S60 2nd to 3rd/ PlatformSecurity / Capabilities jarkoos Installation, Certification and Security 4 2007-04-14 15:08
Conditional compilation: managing set of modules doctordwarf General Symbian C++ 3 2004-08-31 15:01
Modules stenlik Symbian Networking & Messaging 1 2004-06-09 10:30

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 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d81449X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxpythonX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ