Skip to content

Commit 0267293

Browse files
committed
ENH: Improve import error handling to preserve original traceback
1 parent a46dc65 commit 0267293

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

pandas/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
try:
1111
__import__(_dependency)
1212
except ImportError as _e: # pragma: no cover
13-
_missing_dependencies.append(f"{_dependency}: {_e}")
13+
raise ImportError(
14+
f"Unable to import required dependency {_dependency} ..."
15+
) from _e
1416

1517
if _missing_dependencies: # pragma: no cover
1618
raise ImportError(
17-
"Unable to import required dependencies:\n"
18-
+ "\n".join(_missing_dependencies)
19-
+ "\n\nTo see the full error message, "
20-
+ "try importing the missing dependencies directly."
19+
"Unable to import required dependencies:\n" + "\n".join(_missing_dependencies)
2120
)
2221
del _hard_dependencies, _dependency, _missing_dependencies
2322

0 commit comments

Comments
 (0)