Reputation: 18712
I have a Python 2.5 project with following directory structure:
database/__init__.py
database/createDBConnection.py
gui/mainwindow.py
When I try to run
python gui/mainwindow.py
I get the error
C:\PopGen>python gui/mainwindow.py
Traceback (most recent call last):
File "gui/mainwindow.py", line 12, in <module>
from database.createDBConnection import createDBC
ImportError: No module named database.createDBConnection
In mainwindow.py, there is following statement on line 12
from database.createDBConnection import createDBC
The problem occurs because Python can't find the database module.
Question: What can I do in order to fix this error?
Here's the code of the project: https://www.dropbox.com/sh/edfutlba960atp9/MwFpaepEpl
I tried to use
C:\PopGen>python -m gui.mainwindow
but got these errors
Traceback (most recent call last):
File "C:\Python25\lib\runpy.py", line 95, in run_module
filename, loader, alter_sys)
File "C:\Python25\lib\runpy.py", line 52, in _run_module_code
mod_name, mod_fname, mod_loader)
File "C:\Python25\lib\runpy.py", line 32, in _run_code
exec code in run_globals
File "C:\PopGen\gui\mainwindow.py", line 13, in <module>
from file_menu.wizard_window_validate import Wizard
ImportError: No module named file_menu.wizard_window_validate
Upvotes: 1
Views: 4917
Reputation: 11862
There are several ways to fix this, but this is perhaps the easiest one.
Try adding this in mainwindow.py, prior to the import that is failing:
import sys
sys.path.append("C:/path/to/database/module")
Upvotes: 3