Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rich Tracebacks fail on Jupyterlab #1075

Closed
krassowski opened this issue Jan 12, 2023 · 3 comments
Closed

Rich Tracebacks fail on Jupyterlab #1075

krassowski opened this issue Jan 12, 2023 · 3 comments

Comments

@krassowski
Copy link
Member

Description

Rich tracebacks are broken on Jupyterlab. Relevant Rich issue here.

What appears to be happening is that the temporary file where Jupyter runs the cell code from as been removed from the filesystem when Rich comes to inspect it.

Rich will walk the frames in the exception with walk_tb, and look at f_code.co_filename to get the code. But these files don't exists. I'm not certain if the paths are incorrect, or the file as been removed.

Reproduce

from rich.traceback import install
install(show_locals=True)
1/0

Note the absense of code snippets in the traceback. Rich Tracebacks generally show a snippet of relevant code, more than the standard Python tracebacks. This did work in Jupyter until some point last year.

Expected behavior

Troubleshoot Output
$PATH:
	/Users/willmcgugan/.pyenv/versions/3.10.4/bin
	/opt/homebrew/Cellar/pyenv/2.3.9/libexec
	/Users/willmcgugan/.pyenv/plugins/pyenv-virtualenv/bin
	/opt/homebrew/Cellar/pyenv/2.3.9/plugins/python-build/bin
	/Users/willmcgugan/.pyenv/shims
	/Users/willmcgugan/.pyenv/plugins/pyenv-virtualenv/shims
	/Users/willmcgugan/.local/bin
	/opt/homebrew/opt/[email protected]/bin
	/Users/willmcgugan/.nvm/versions/node/v14.19.1/bin
	/Users/willmcgugan/.pyenv/plugins/pyenv-virtualenv/shims
	/opt/homebrew/bin
	/opt/homebrew/sbin
	/usr/local/bin
	/System/Cryptexes/App/usr/bin
	/usr/bin
	/bin
	/usr/sbin
	/sbin

sys.path:
/Users/willmcgugan/.pyenv/versions/3.10.4/bin
/Users/willmcgugan/.pyenv/versions/3.10.4/lib/python310.zip
/Users/willmcgugan/.pyenv/versions/3.10.4/lib/python3.10
/Users/willmcgugan/.pyenv/versions/3.10.4/lib/python3.10/lib-dynload
/Users/willmcgugan/.pyenv/versions/3.10.4/lib/python3.10/site-packages
/Users/willmcgugan/projects/ganglion/src
/Users/willmcgugan/projects/textual-dev/src

sys.executable:
/Users/willmcgugan/.pyenv/versions/3.10.4/bin/python3.10

sys.version:
3.10.4 (main, Aug 23 2022, 17:03:22) [Clang 13.1.6 (clang-1316.0.21.2.5)]

platform.platform():
macOS-13.1-arm64-arm-64bit

which -a jupyter:
/Users/willmcgugan/.pyenv/versions/3.10.4/bin/jupyter
/Users/willmcgugan/.pyenv/shims/jupyter

pip list:
Package Version Editable project location


aioconsole 0.5.1
aiohttp 3.8.3
aiosignal 1.2.0
anyio 3.6.2
appnope 0.1.3
argon2-cffi 21.3.0
argon2-cffi-bindings 21.2.0
arrow 1.2.3
asttokens 2.2.1
async-timeout 4.0.2
attrs 22.2.0
Babel 2.11.0
backcall 0.2.0
beautifulsoup4 4.11.1
bleach 5.0.1
certifi 2022.9.24
cffi 1.15.1
charset-normalizer 2.1.1
click 8.1.2
comm 0.1.2
commonmark 0.9.1
debugpy 1.6.5
decorator 5.1.1
defusedxml 0.7.1
distlib 0.3.6
editables 0.3
entrypoints 0.4
executing 1.2.0
fastapi 0.88.0
fastjsonschema 2.16.2
filelock 3.8.0
fqdn 1.5.1
frozenlist 1.3.1
ganglion 0.0.0 /Users/willmcgugan/projects/ganglion/src
h11 0.12.0
hatch 1.6.3
hatchling 1.11.1
httpcore 0.15.0
httptools 0.5.0
httpx 0.23.0
hyperlink 21.0.0
idna 3.4
importlib-metadata 4.13.0
ipykernel 6.20.1
ipython 8.8.0
ipython-genutils 0.2.0
isoduration 20.11.0
jaraco.classes 3.2.3
jedi 0.18.2
Jinja2 3.1.2
json5 0.9.11
jsonpointer 2.3
jsonschema 4.17.3
jupyter_client 7.4.8
jupyter_core 5.1.3
jupyter-events 0.6.2
jupyter_server 2.0.6
jupyter_server_terminals 0.4.4
jupyterlab 3.5.2
jupyterlab-pygments 0.2.2
jupyterlab_server 2.18.0
keyring 23.9.3
MarkupSafe 2.1.1
matplotlib-inline 0.1.6
mistune 2.0.4
more-itertools 9.0.0
msgpack 1.0.4
multidict 6.0.2
nanoid 2.0.0
nbclassic 0.4.8
nbclient 0.7.2
nbconvert 7.2.7
nbformat 5.7.2
nest-asyncio 1.5.6
notebook 6.5.2
notebook_shim 0.2.2
packaging 21.3
pandocfilters 1.5.0
parso 0.8.3
pathspec 0.10.1
pexpect 4.8.0
pickleshare 0.7.5
pip 22.0.4
platformdirs 2.5.2
pluggy 1.0.0
prometheus-client 0.15.0
prompt-toolkit 3.0.36
psutil 5.9.4
ptyprocess 0.7.0
pure-eval 0.2.2
pycparser 2.21
pydantic 1.10.4
Pygments 2.13.0
pyparsing 3.0.9
pyperclip 1.8.2
PyQt6 6.3.1
PyQt6-Qt6 6.3.1
PyQt6-sip 13.4.0
pyrsistent 0.19.3
python-dateutil 2.8.2
python-dotenv 0.21.0
python-json-logger 2.0.4
pytz 2022.7
PyYAML 6.0
pyzmq 24.0.1
requests 2.28.1
rfc3339-validator 0.1.4
rfc3986 1.5.0
rfc3986-validator 0.1.1
rich 13.0.0
Send2Trash 1.8.0
setuptools 58.1.0
shellingham 1.5.0
six 1.16.0
sniffio 1.3.0
soupsieve 2.3.2.post1
stack-data 0.6.2
starlette 0.22.0
terminado 0.17.1
textual-dev 0.0.1 /Users/willmcgugan/projects/textual-dev
tinycss2 1.2.1
tomli 2.0.1
tomli_w 1.0.0
tomlkit 0.11.5
tornado 6.2
traitlets 5.8.1
typer 0.7.0
typing_extensions 4.4.0
uri-template 1.2.0
urllib3 1.26.14
userpath 1.8.0
uvicorn 0.20.0
uvloop 0.17.0
virtualenv 20.16.5
watchfiles 0.18.1
wcwidth 0.2.5
webcolors 1.12
webencodings 0.5.1
websocket-client 1.4.2
websockets 10.4
yarl 1.8.1
zipp 3.8.1

Originally reported in jupyterlab/jupyterlab#13759 by @willmcgugan (thank you!)

@davidbrochart
Copy link
Collaborator

@willmcgugan I believe you fixed this issue in Textualize/rich#2754?

@willmcgugan
Copy link

Worked around it. The code from the cells is available via the linecache module.

@davidbrochart
Copy link
Collaborator

Great, I'm closing this issue then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants