[PyQt] Eric3 issue: importing modules with the same name as an Eric module

Sundance sundance at ierne.eu.org
Wed Sep 26 09:20:04 BST 2007

Detlev Offenbach wrote:

> That is strange. eric puts the path of the executable at sys.path[0]
> just before it's own path. Can you check sys.path in your main
> routine or just before the failing import?

Hi Detlev,

Thank you for your reply!

I did check sys.path just before the failing import. This being said, I 
don't think sys.path is used at all here, as you will see below.

Anyway, here's how to reproduce the bug: create these two files:

---[ test.py ]---------------------------------------------------------
import sys
print "Path:"
print sys.path

import Config
print "Config file:"
print Config.__file__

---[ Config.py ]-------------------------------------------------------
print "I am the Config.py file!"

... and run test.py from Eric.

The output will be something like this:

---[ (output) ]--------------------------------------------------------
['/home/me', '/usr/share/eric/modules/DebugClients/Python', '/usr/share/eric/modules', ...]
Config file:

As you can see, the sys.path is correct, but the wrong Config module is 

What is happening here is, I think, that the Python interpreter instance 
which Eric starts in order to run my program, isn't 'clean': it imports 
its own Config module BEFORE even running my code, and thus, when my 
code tries to 'import Config', that Python interpreter goes, "Oh, but I 
already have a Config module loaded, so I'll just return a reference to 
that one".

Am I correct in my assumption that the Python interpreter instance loads 
its own Config module before running my code? Or is it a bug?


-- S.

More information about the PyQt mailing list