×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    43

    1.9.5 "Import error: No module named..." Works fine on 1.4.5

    Hi:


    I have the typical import error. I'm trying to import a module I did and placed under e:\Python so I added the needed


    Code:
    sys.path.append('e:\\Python\\')
    ... so the path is found.

    That used to work in 1.4.5 but the error is showing on 1.9.5


    What could be wrong ?

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: 1.9.5 "Import error: No module named..." Works fine on 1.4.5

    Quote Originally Posted by carlosl View Post
    Hi:


    I have the typical import error. I'm trying to import a module I did and placed under e:\Python so I added the needed


    Code:
    sys.path.append('e:\\Python\\')
    ... so the path is found.

    That used to work in 1.4.5 but the error is showing on 1.9.5


    What could be wrong ?

    hello carlosl

    strange i just tried the following code in PyS60 1.9.5 and it worked excellent:

    Code:
    import sys
    sys.path.append('e:\Python')
    import ball
    I guess you are importing a script which is not coded for the 1.9.x releases.

    Moreover i hope you are not importing the script before specifying the path.

    Enjoy Pythoning
    Gaba88

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    43

    Re: 1.9.5 "Import error: No module named..." Works fine on 1.4.5

    Thanks Gaba...



    I'm pulling my hair now


    I have several modules I created and placed at "e:\Python"...


    Some of them are being imported and some are not... so it's not the path after all.

    What could it be ?

    I have this in my main program

    Code:
    import e32
    import sys
    import appuifw
    
    #to be able to import our libraries from SD memory
    sys.path.append('e:\\Python')
    
    import uiClient
    import filehandlingClient
    import sms
    import tcpip
    All 4 imports after the sys.path are on Python dir en e:

    It fails on sms and/or tcpip as follows:



    Traceback (most recent call last): File "default.py", line 102, in menu_action f()
    File: "default.py", line 70, in query_and_exec script_namespace.namespace)
    File: "e:\python\mainprogram.py", line 16, in <module> import sms
    File: "c:\resource\python25\python25.zip\site.py", line 109, in platsec_import raise ImportError("No module named " + name) ImportError: No module named sms

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

    Re: 1.9.5 "Import error: No module named..." Works fine on 1.4.5

    The module names are case sensitive in PyS60 1.9.x series (more compliant with standard Python).
    So, check the filenames of the these modules. In this case, are modules sms & tcpip with filenames sms.py and tcpip.py respectively ?

  5. #5
    Registered User
    Join Date
    Oct 2008
    Posts
    43

    Re: 1.9.5 "Import error: No module named..." Works fine on 1.4.5

    Thanks mahesh. Yes, both are lowercase and I'm using lowercase names at the import.


    I'm now suspecting its the python itself. I was making tests on the interactive console, trying to do the sys.path.append and imports from there. While trying to add to the path list I just couldn't make it work. Not even that.

    Then I suspected some commands were not being executed. Then I started inputing random names, like for inspecting variables values and nothing happened. No "name 'dsd' is not defined" messages at all. This weird behavior ended when I exited the shell and entered again.

    How about that...

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

    Re: 1.9.5 "Import error: No module named..." Works fine on 1.4.5

    PyS60 ScriptShell seems to do more buffering & caching than 1.4.5. Got to exit and restart more often than previously...

    Cheers,

    --jouni

  7. #7
    Registered User
    Join Date
    Oct 2008
    Posts
    43

    Re: 1.9.5 "Import error: No module named..." Works fine on 1.4.5

    I renamed my module to Sms.py (uppercase initial) and changed the import to "import Sms" and it's working fine now. I did so since the two other modules that were being imported correctly had upercase characters in their names.


    I don't know the root cause of the problem but I suspect something related to character encoding since I'm outputting spanish messages to the UI and I had "illegal character" errors with extended characters ( á é í ó ú).

  8. #8
    Registered User
    Join Date
    Oct 2008
    Posts
    43

    Unhappy Re: 1.9.5 "Import error: No module named..." Works fine on 1.4.5

    I kind of found what the problem is... tough I'm still trying to find out a solution.


    Help is still welcome...


    What happens is that any file named with only lowercase characters shows on e: (SD card) as all uppercase. The case remains correct if the file name has at least one uppercase/number/special chracter. This is only from Python perspective and not from Windows (i.e. when listing e:\Python files ) or selecting which script to run. Same case changing thing happened before when I was using 1.4.5 on 3rd ed, but python was case insensitive then.


    But still....

    I tried using "import SMS" and it's still not working.



    Any ideas????
    Last edited by carlosl; 2009-06-18 at 00:58.

  9. #9
    Registered User
    Join Date
    Oct 2008
    Posts
    43

    Re: 1.9.5 "Import error: No module named..." Works fine on 1.4.5

    Just found a workaround...


    The problem, by the way, was reported back in January. And the status is closed.



    https://garage.maemo.org/tracker/ind...=854&atid=3201

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

    Re: 1.9.5 "Import error: No module named..." Works fine on 1.4.5

    Quote Originally Posted by carlosl View Post
    Just found a workaround...
    Can you share it, might help others as well.

    The problem, by the way, was reported back in January. And the status is closed.

    https://garage.maemo.org/tracker/ind...=854&atid=3201
    Please update this bug with your findings, we shall reopen it and investigate further.

  11. #11
    Registered User
    Join Date
    Oct 2008
    Posts
    43

    Re: 1.9.5 "Import error: No module named..." Works fine on 1.4.5

    The workaround is described in the comments for the original bug, that is:

    https://garage.maemo.org/tracker/ind...=854&atid=3201

    It only consists in using os.rename to rename the files.

    I created a new thread to show the specific details of what I found:

    http://discussion.forum.nokia.com/fo...d.php?t=171242
    Last edited by carlosl; 2009-06-19 at 22:19.

Similar Threads

  1. ImportError: No module named _appuifw
    By ernesto.ferrari in forum Mobile Web Server
    Replies: 9
    Last Post: 2008-04-18, 05:36
  2. Carbide.j 1.5 and Netbeans 5.5 beta 2
    By ovjo12 in forum Mobile Java Tools & SDKs
    Replies: 5
    Last Post: 2007-06-11, 05:43
  3. Replies: 4
    Last Post: 2007-05-24, 04:06
  4. No module named messeging
    By bintelnoor in forum Symbian
    Replies: 7
    Last Post: 2006-05-20, 00:55
  5. Problem loading sounds on MIDP2.0 (works fine with 1.0)
    By anacondabbs in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2005-08-18, 22:26

Posting Permissions

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