473,809 Members | 2,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.surfarra y
File "/usr/lib/python2.5/site-packages/Numeric/Numeric.py", line 536,
in <module>
class Unpickler(pickl e.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 1926
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.pickl e` 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
1614
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: def __init__(self): self.x=23
2
9530
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
5237
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 library's curses module. Is there any (reliable) way to access a module of the standard library if the names conflict as in this case?
2
2700
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: ... does not work anymore, with this error msg:
3
3825
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 'import os\ndef test():\n print os.getcwd()' > os.py cd /tmp
9
11320
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 file has been copied to site-packages/mypackage, but I cant do from mypackage import mymodule Could I get suggestions as to why a module would be installed but not registered?
6
1404
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 accepts(*types): > def check_accepts(f): > assert len(types) == f.func_code.co_argcount
1
3233
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 stumbling on a problem that I am almost certain is a problem with my inputs to the script. The program has a debug mode that is giving me some very weird results. Here's what the script does: It takes a spreadsheet like this: Column1 Column2 ...
2
2254
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 and see the database, no rows are inserted. I redirected the output to another file. It shows success for all inserts, but no rows in database. This is happening only when the PC has IP clash, that too not all times. I wasn't able to trace out...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10640
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.