Import question

Discussion in 'Python' started by Fred Lionetti, Sep 11, 2003.

  1. Hi everyone,

    Hopefully a quick question for someone out there--

    If I have a file at C:\Python23\myfolder\mymodule.py

    why can't I say (from python prompt or anywhere else):
    import myfolder.mymodule ????

    When I try to do that I get the following error message:
    ImportError: No module named myfolder.mymodule

    Yet, myfolder really is in that location, and the sys.path includes
    "C:\Python23\"

    If I try appending "C:\Python23\myfolder" to sys.path then I can say import
    mymodule, and it works--but that creates other problems with the file I'm
    working with.

    Any ideas????

    Thanks,
    Fred
    Fred Lionetti, Sep 11, 2003
    #1
    1. Advertising

  2. "Fred Lionetti" <>

    > If I have a file at C:\Python23\myfolder\mymodule.py
    >
    > why can't I say (from python prompt or anywhere else):
    > import myfolder.mymodule ????


    It might help to put an empty file named __init__.py into 'myfolder'
    Kindly
    Michael P
    Michael Peuser, Sep 11, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Opal
    Replies:
    12
    Views:
    940
    Paul Opal
    Oct 11, 2004
  2. JPractitioner
    Replies:
    13
    Views:
    20,142
    Roedy Green
    Feb 24, 2006
  3. Vitali Gontsharuk
    Replies:
    2
    Views:
    561
    Vitali Gontsharuk
    Aug 25, 2005
  4. Artur M. Piwko

    import/from import question

    Artur M. Piwko, Jun 29, 2003, in forum: Python
    Replies:
    1
    Views:
    834
    Peter Hansen
    Jul 2, 2003
  5. Dennis
    Replies:
    2
    Views:
    499
    Dennis
    Aug 18, 2003
Loading...

Share This Page