import

David Jackson jacksond at dickinson.edu
Wed Jul 5 16:41:30 EDT 2006


Hi all,

I'm a real beginner with python but have what I think is a simple question. 
I am writing some simple modules and would like to place them into a 
subdirectory.  But then I cannot seem to import them.  I have tried the 
following.

I wrote a module called fibo.py with some definitions in it (one called 
fibo).  In the same directory, I wrote another file (test.py) and began with 
import fibo.  This worked fine and I was able to use the function fibo as 
fibo.fibo.  Then, I made a directory called test and placed the file fibo.py 
in this directory.  I also placed a blank file called _init_.py into this 
directory.  I went back to the original directory and tried to import 
test.fibo but this fails.  I get the following error message:

Traceback (innermost last)
  File "...test.py", line 1, in ?
    import test.fibo
  File "...test.py", line 1, in ?
    import test.fibo
ImportError: No module named fibo

Any help would be greatly appreciated.  If it makes any difference, I'm 
working on a Mac, OSX 10.3.9

Thanks,
David 





More information about the Python-list mailing list