General module name clash problem?

jipjip jipjip at arcor.de
Fri Oct 19 07:09:22 EDT 2007


Hello all,
just new to python..

Suppose i have a directory only with an empty file "pickle.py".
In this directory i start the python interpreter and say:
 >>> import pygame

What happens?
I get an error message:

Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/usr/lib/python2.5/site-packages/pygame/__init__.py", line 147, 
in <module>
     try: import pygame.surfarray
   File "/usr/lib/python2.5/site-packages/Numeric/Numeric.py", line 536, 
in <module>
     class Unpickler(pickle.Unpickler):
AttributeError: 'module' object has no attribute 'Unpickler'

Why?
Because pygame needs a module namend "pickle.py"!
The first location python searches is my directory, so
the library module "pickle.py" is overwritten with my "pickle.py".

The cause of this error is not that i import 2 different modules with 
the same name, it's only because there is a file in my directory with 
the same name of a module somewhere in the imported module tree.

I mean, this is a general problem.
Must i look for every module that gets importet for not clashing
with my module files residing in the calling directory?

Is the python package system insufficient, is there something wrong with 
my opinions or do i need a "gotcha"?

Thank's in advance,
jipjip



More information about the Python-list mailing list