Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions python/pyspark/errors/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,20 @@ def _capture_call_site(spark_session: "SparkSession", depth: int) -> str:

# We try import here since IPython is not a required dependency
try:
from IPython import get_ipython

ipython = get_ipython()
import IPython

# ipykernel is required for IPython
import ipykernel # type: ignore[import-not-found]

ipython = IPython.get_ipython()
# Filtering out IPython related frames
ipy_root = os.path.dirname(IPython.__file__)
ipykernel_root = os.path.dirname(ipykernel.__file__)
selected_frames = [
frame
for frame in selected_frames
if (ipy_root not in frame.filename) and (ipykernel_root not in frame.filename)
]
except ImportError:
ipython = None

Expand Down