473,326 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

General module name clash problem?

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
Oct 19 '07 #1
1 1903
On Fri, 19 Oct 2007 13:09:22 +0200, jipjip wrote:
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?
Yes.
Is the python package system insufficient, is there something wrong with
my opinions or do i need a "gotcha"?
The package system is not insufficient but could solve your problem
actually. Don't put all your modules simply in the same directory but in a
package so that your `whatever.pickle` does not clash with the standard
`pickle` anymore.

Ciao,
Marc 'BlackJack' Rintsch
Oct 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Glenn Reed | last post by:
Hi, This is probably a really easy question and I apologize if it is already covered in some faq somewhere. These are my two source files: ------- module1.py ------------- class module2:...
2
by: dont bother | last post by:
Hey, I am trying to run the following example from diveintopython import urllib sock = urllib.urlopen("http://diveintopython.org/") htmlSource = sock.read() sock.close() print htmlSource
8
by: Felix Wiemann | last post by:
Hi! I want to create a module myproject.ui.curses, which needs to import the curses library. However, if I just write ``import curses``, the module imports *itself* instead of the standard...
2
by: Olivier Vierlinck | last post by:
Hi, I've a python script using somecalls to the abs() built-in function. Now, I have to import a module named 'abs' too... The consequence if that line code like if (abs(a-b) < epsilon:...
3
by: George P | last post by:
I've run into a strange package related namespace problem. Follow these steps (on UNIX system) to illustrate: ------------------------- mkdir /tmp/mypkg cd /tmp/mypkg touch __init__.py echo...
9
by: Darren Dale | last post by:
I have built two basic modules using distutils. One of them installs fine, but the other, I can't import modules from it. I've been pouring over the code and I cant find the problem. I know the...
6
by: Michele Simionato | last post by:
could ildg wrote: > I think decorator is a function which return a function, is this right? > e.g. The decorator below if from http://www.python.org/peps/pep-0318.html#id1. > > def...
1
by: gcook | last post by:
Hi, I've got an old perl program running on my webserver - so old that I haven't used a perl programmer in about two years :) (we've gone all php for a variety of reasons). Anyway, I'm...
2
by: Deepa K | last post by:
Hi, In my PC, eth0 is not up because of IP address clash (another PC is using the same IP address). I tried to execute a file which has set of insert commands. After executing the file, when I go...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.