×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    3

    Help---cannot import name ...

    Hi ,all, this is what i met in S60 SDK 3rd edition:
    I put a python script in c:\python , named 1.py,
    #1.py
    #######################################
    from mymodule import findarraytype
    import sys
    print findarraytype()

    and i put mymodule.py in c:\python\lib (the same in c:\resource) :
    #mymodule.py
    #######################################
    from ZSI.wstools.Namespaces import SOAP as _SOAP, SCHEMA as _SCHEMA
    import sys
    def findarraytype():
    print _SOAP.ENC
    if __name__ == '__main__'rint findarraytype()
    #######################################
    and when i run 1.py, got an error:
    cannot import name findarraytype, when i run mymodule.py, it works fine,what's the problem here ? why i cannot make mymodule.py a module ?? Thanks!

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

    Re: Help---cannot import name ...

    Hello 03jsjly_zju

    Modules that you install on your device have to be the .pyd file that you install as a Python Library module.
    Pankaj Nathani
    www.croozeus.com

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    3

    Re: Help---cannot import name ...

    hi, croozeus, thanks for your reply, but how I can make mymodule.py be a .pyd file ??if i do not import "from ZSI.wstools.Namespaces import SOAP as _SOAP, SCHEMA as _SCHEMA", and change mymodule.py like this :
    #mymodule.py
    #####################################
    import sys
    def findarraytype():
    print 'hi'
    if __name__ == '__main__'rint findarraytype()
    #####################################
    then run 1.py, it also works fine

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

    Re: Help---cannot import name ...

    Hi 03jsjly_zju,

    Some clarifications here. With Python you have 2 type of libraries: the python libraries (100% in Python) which have the .py or .pyc and the DLL .pyd written in C/C++.

    You can of course make your own Python libraries for PyS60 and the easiest way to install them on a phone for debuggin is to push them in E:\\python\\lib (without s at the end). If that directory does not exist, create it the Python shell imports all the files inside if it finds inside (+ sub folders...).

    If you have some imports error in your library there will be no trace on the phone.

    Code:
    from ZSI.wstools.Namespaces import SOAP as _SOAP, SCHEMA as _SCHEMA
    I think you are trying to import some ZOPE libraries. This API hasn't been ported (not that I know). Or is it 100% Python and compatible with Python 2.2.2??? not sure, for you to try.

    You can for example make sure that a library is installed that way:
    Code:
    try:
        from ZSI.wstools.Namespaces import SOAP as _SOAP, SCHEMA as _SCHEMA
    except ImportError:
        import sys
        sys.exit("ZSI missing")

    And please next time you post some source, surround it with CODE tags (the # button)

    I hope this help

    LFD
    Devices:
    Nokia E61 3rd Edition - pys60 1.4.0

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

  5. #5
    Registered User
    Join Date
    Sep 2007
    Posts
    3

    Re: Help---cannot import name ...

    Thank you, lfd. but why I run mymodule.py, not make it as a module, it works fine:
    #mymodule.py
    Code:
    from ZSI.wstools.Namespaces import SOAP as _SOAP
    import sys
    
    def findarraytype():
     print _SOAP.ENC
    
    if __name__ == '__main__':print findarraytype()
    when I run this script, it can ex findarraytype and print value of _SOAP.ENC,
    and when I run the code you told me:
    Code:
    try:
        from ZSI.wstools.Namespaces import SOAP as _SOAP, SCHEMA as _SCHEMA
    except ImportError:
        import sys
        sys.exit("ZSI missing")
    it prints "ZSI missing", seems that this module can not be imported, what's the problem here? thanks!

Similar Threads

  1. GoogleIt
    By deepika.mangla in forum Symbian
    Replies: 5
    Last Post: 2011-05-28, 11:04
  2. SyExpat + problem + memmove + Carbide Express
    By pearman in forum Symbian
    Replies: 2
    Last Post: 2006-10-14, 22:21
  3. pim groups
    By Nedferatus in forum Mobile Java General
    Replies: 2
    Last Post: 2006-07-13, 07:30
  4. DemoDMServer SMS problem
    By kudelasz in forum OMA DM/DS/CP
    Replies: 17
    Last Post: 2006-05-22, 09:16
  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
  •  
×