Skip to content

Commit d654883

Browse files
Added additional debugging output to pyface/qt/__init__.py. (#1230)
Responding to issue 1205, by adding some additional debugging output when importing a GUI backend fails. Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
1 parent 9511063 commit d654883

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pyface/qt/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,20 @@
3535

3636
# if we have no preference, is a Qt API available? Or fail with ImportError.
3737
if qt_api is None:
38+
msg = "Nothing found in sys.modules or os.environ.\n"
39+
msg += "Attempting to import...\n"
3840
for api_name, module in QtAPIs:
3941
try:
4042
importlib.import_module(module)
43+
msg += f"Successfully imported {module}\n"
4144
importlib.import_module(".QtCore", module)
4245
qt_api = api_name
4346
break
44-
except ImportError:
47+
except ImportError as err:
48+
msg += f"Failed to import {err.name}; problem involved: {err.path}.\n"
4549
continue
4650
else:
47-
raise ImportError("Cannot import any of " + ", ".join(modules))
51+
raise ImportError(msg + "Cannot import any of " + ", ".join(modules))
4852

4953
# otherwise check QT_API value is valid
5054
elif qt_api not in api_names:

0 commit comments

Comments
 (0)