×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    2

    How to import a custom module?

    Hi there,

    I want to use some python modules to S60, that are not part of the original distribution. I tried to put the module along with the main source file into the e:/Python directory, but that does not work (ImportError, module not found).

    Am I missing something obvious?
    The module I want to use is json.py from Jürgen Scheible.
    Is there a way to put it into the "lib" directory of the python interpreter?

    Cheers,
    Alex

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: How to import a custom module?

    Hi Alex and welcome to the Python discussion board.

    You can put your module (in this case .py file) pretty much anywhere, but you have to let Python know where to look for it.

    1)You can put it in E:\\Resource, in which case you can import it without problems
    or
    2)Put it wherever you want and do this to "tell" Python where it is:
    Code:
    #For example you want to put it in E:\\Python
    
    import sys
    
    sys.path.append("E:\\Python")
    
    #Now just import it
    import mymodule

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    2

    Re: How to import a custom module?

    Hi Bogdan,

    wow, thanks very much for your fast response!
    It works!!

    Cheers,
    Alex

  4. #4
    Registered User
    Join Date
    Mar 2008
    Location
    Frankfurt, Germany
    Posts
    35

    Re: How to import a custom module?

    may i ask how i have to use py2sis to get a sis-file which places the "ensymbled" py-file in a certain folder (e.g. the resource-folder)?

    kind regards

  5. #5
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: How to import a custom module?

    Quote Originally Posted by szallah View Post
    may i ask how i have to use py2sis to get a sis-file which places the "ensymbled" py-file in a certain folder (e.g. the resource-folder)?

    kind regards
    I guess you could use Ensymble's simplesis function. Make a folder (in this case "myfolder" which contains a folder named "resource" and in that your py file; "myfolder" is necessary as simplesis gets the contents of the folder, not the folder itself) and use
    Code:
    python ensymble.py simplesis myfolder myfolder.sis
    Also, read Ensymble's documentation for more info.

    Is that what you wanted?
    Last edited by bogdan.galiceanu; 2008-06-25 at 12:51. Reason: typo

  6. #6
    Registered User
    Join Date
    Mar 2008
    Location
    Frankfurt, Germany
    Posts
    35

    Re: How to import a custom module?

    @bogdan.galiceanu

    that's exactly what i meant. thanks very much.

    EDIT:
    the documentation doesn't say anything about adding capabilities when using simplesis... is there a workaround for that so the installed py-file get's the needed capabilities?

  7. #7
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: How to import a custom module?

    OK, now I'm not sure I understood your request. You asked if you could put a file in a specific folder, right? If so, the file itself doesn't get installed, it's just placed into that folder. That's why you don't need capabilities.

    Please correct me if I'm wrong or if it was something else you wanted

  8. #8
    Registered User
    Join Date
    Mar 2008
    Location
    Frankfurt, Germany
    Posts
    35

    Re: How to import a custom module?

    what i mean is:
    i have a py-file (which i want to use as a module), which does something that requires certain capabilities to execute correctly.
    like, hhmm, the module relies on something like location-requestor or lightblue or whatever. just something, that requires capabilities.
    or it does somethign itself which requires capabilties (like writing data to system-folders).

    but it seems like i've generally misunterstood something, since the py-file itself proboably won't even need capabilities, just the application that makes use of the py-file... is this true?

  9. #9
    Super Contributor
    Join Date
    May 2004
    Location
    Tampere, Finland
    Posts
    524

    Re: How to import a custom module?

    Quote Originally Posted by szallah View Post
    the documentation doesn't say anything about adding capabilities when using simplesis... is there a workaround for that so the installed py-file get's the needed capabilities?
    Only EXE-files (*) have capabilities. Pure Python extensions have the capabilities of their calling EXE, which is usually the EXE stub generated by Ensymble when using the py2sis command.


    *) DLLs and PYDs (Python extensions which are written in C++ and are actually DLLs) have capabilities too, but those capabilities do not enable the DLL to use features governed by those capabilities. Capabilities in DLLs only determine whether an EXE is allowed to load the DLL in question.

Similar Threads

  1. GoogleIt
    By deepika.mangla in forum Symbian
    Replies: 5
    Last Post: 2011-05-28, 11:04
  2. Error import module
    By akus in forum Symbian
    Replies: 0
    Last Post: 2007-10-21, 19:47
  3. problem on running my application
    By rsf in forum Symbian
    Replies: 7
    Last Post: 2007-10-21, 15:56
  4. Replies: 2
    Last Post: 2007-06-25, 10:18
  5. 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

Posting Permissions

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