[Tutor] Module search path problem

Kent Johnson kent37 at tds.net
Tue Feb 27 13:25:52 CET 2007


Christer Enfors wrote:
> I have two files, in the same directory: main.py, and user.py
> 
> This works without problems.
> 
> But then I tried moving user.py to a subdirectory, and adding that 
> directory to Python's module search path

> 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?

There is a library module called 'user'. Since you appended to sys.path 
your program is finding the library module instead of your own.

Best solution is to rename your module to something else.

Kent


More information about the Tutor mailing list