Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ImportError in eric4

1 view
Skip to first unread message

rhill

unread,
Dec 23, 2009, 8:02:25 AM12/23/09
to
I am new to Linux/Python/Eric4 (not in development though).

So I am trying to start a small application as per tutorial found at
eric-ide.python-projects.org:

http://eric-ide.python-projects.org/tutorials/LogParser/chap1.html

My application is similarly structured. Final step, I try to execute it
(Run Project...), and I get:

/=====
The debugged program raised the exception unhandled ImportError
"No module named ui.MainWindow"
File: /home/xxx/xxx/my first project/main.py, Line: 4
Break here?
\=====

Here is the content of main.py:

/=====
#!/usr/bin/python

from PyQt4.QtGui import QApplication
from ui.MainWindow import MainWindow

def main():
import sys
app = QApplication(sys.argv)
wnd = MainWindow()
wnd.show()
sys.exit(app.exec_())

if __name__ == '__main__':
main()
\=====

As per tutorial. The file MainWindow.py *really* exists, and is *really*
located inside the folder 'ui' which itself is inside 'my first project'
(the root of the project I am working on.)

I couldn't find anything meaningful help through google, so here I am.

Why is the file ./ui/MainWindow.py not seen by the python interpreter?

Steven D'Aprano

unread,
Dec 23, 2009, 9:00:35 AM12/23/09
to
On Wed, 23 Dec 2009 11:02:25 -0200, rhill wrote:

> Why is the file ./ui/MainWindow.py not seen by the python interpreter?

My wild guess is that you haven't set up a package correctly. You need to
include a file __init__.py in the ui folder for Python to recognise it
correctly. Note that the file doesn't need to include anything, it just
needs to exist. Also note that the file name has TWO underscores before
and after the "init", that is:

underscore underscore i n i t underscore underscore dot p y


--
Steven

rhill

unread,
Dec 23, 2009, 9:14:15 AM12/23/09
to

Thank you very much! That fixed the problem. That also adds a bit to my
understanding of the concept of 'package,' eventually all the pieces
will fit together.

0 new messages