[Tutor] Module search path problem

Christer Enfors enfors at enfors.net
Tue Feb 27 11:28:10 CET 2007


I have two files, in the same directory: main.py, and user.py I have the 
following code in main.py:

   ----main.py----
   import user

   [snip]

   user_man = user.UserMan()
   -----end-----

This works without problems.

But then I tried moving user.py to a subdirectory, and adding that 
directory to Python's module search path, so this is what main.py looks 
like now:

   ----main.py---
   import sys
   sys.path.append("/correct/complete/path/to/subdir")

   import user  # Generates no error message, so it's finding user.py

   [snip]

   user_man = user.UserMan()
   -----end-----

But now I get an error message for the last line shown above:

   ----start----
   Traceback (most recent call last):
     File "./main.py", line 56, in ?
       driver.boot()
     File "./main.py", line 34, in boot
       user_man = user.UserMan()
   AttributeError: 'module' object has no attribute 'UserMan'
   -----end-----

What's up with this?


More information about the Tutor mailing list