mattcen,
@mattcen@aus.social avatar

Can somebody familiar with #JupyterLab or #JupyterNotebook please tell me why the top cell in this notebook doesn't render the HTML, when the other two cells do? Everything I'm reading online suggests it should render it. https://gist.github.com/mattcen/c5db6e729dfe9e949596ffb87207cb1b
In the "Rich representation" section of this notebook (https://jupyterlite.github.io/demo/lab?path=.%2Fpython.ipynb) it does something similar and Just Works (obviously that's #Pyodide rather than CPython, but I don't think that should matter).
I am guessing maybe there's a library I haven't installed; for this example I just created a new virtual environment and installed jupyterlab and nothing else.
#Jupyter #IPython

mattcen, (edited )
@mattcen@aus.social avatar

Found it!
A while ago I copied this PYTHONSTARTUP file, and the highlighted lines were the culprits: https://gist.github.com/ksamuel/ef08e2bd4bcd0bbbf733e521eca967ee#file-pythonstartup-py-L37-L38 (from https://www.bitecode.dev/p/happiness-is-a-good-pythonstartup). As soon as I commented out that line and re-started JupyterLab, it behaved as expected. 😅

/CC @KathyReid @allanchain
@somewheresouth @moshez #JupyterLab #JupyterNotebook #Jupyter #IPython

KathyReid,
@KathyReid@aus.social avatar
somewheresouth,

@mattcen @KathyReid @allanchain @moshez
Cool, I haven't seen one of those before. The doctest mode magic looks useful.

allanchain,

@mattcen Maybe you need a fresher environment. Something like

export JUPYTERLAB_DIR=jupyter JUPYTERLAB_SETTINGS_DIR=settings JUPYTERLAB_WORKSPACE_DIR=workspace
jupyter lab build

Or try in docker.

mattcen,
@mattcen@aus.social avatar

@allanchain Thanks for your suggestions! Doing a jupyter lab build just rebuilds the client-side JavaScript as I understand it (and having just tried it, I can see that's the majority of the files that got created in jupyter/), and this is definitely a server-side issue since Python is the bit sending back the output. This suggestion didn't work for me unfortunately.

Using Docker (specifically the jupyter/minimal-notebook image) did the trick though, so thanks for that! Now I just need to work out what's different between those environments!

mattcen,
@mattcen@aus.social avatar

@moshez Do you happen to have any ideas on this?

KathyReid,
@KathyReid@aus.social avatar

@mattcen it is displaying for me when executed in my jupyterlab env.

Here is a list of my relevant libs from the venv I am in

$ pip list | grep -i python
ipython 8.14.0
ipython-genutils 0.2.0
python-dateutil 2.8.2
python-json-logger 2.0.7

$ pip list | grep -i jupyter
jupyter 1.0.0
jupyter_client 7.4.9
jupyter-console 6.6.3
jupyter_core 5.3.1
jupyter-events 0.7.0
jupyter-lsp 2.2.0
jupyter_server 2.7.0
jupyter_server_fileid 0.9.0
jupyter_server_proxy 4.0.0
jupyter_server_terminals 0.4.4
jupyter_server_ydoc 0.8.0
jupyter-ydoc 0.2.5
jupyterlab 3.6.5
jupyterlab-gruvbox-dark 0.1.0
jupyterlab-pygments 0.2.2
jupyterlab_server 2.24.0
jupyterlab-widgets 3.0.8

mattcen,
@mattcen@aus.social avatar

@KathyReid Thanks for the input, Kathy! I just installed all of these in my venv and restarted Jupyter, and it still doesn't display the HTML! What the heck is going on!? Guess I'll keep digging. 🙂
Thanks again!

KathyReid,
@KathyReid@aus.social avatar

@mattcen sorry Matt, no idea

somewheresouth,

@mattcen hi, I did a quick search for you and I'm not sure if this will work, but maybe try passing raw=True in. Seems to me like your function call is returning an HTML python object instead of your rendered HTML? This might be exactly what you meant, in which case I'm sorry.. https://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html
Could be wrong, was just interested as I've been meaning to use IPython.display more as it looks really useful. Please let me know if so.

mattcen,
@mattcen@aus.social avatar

@somewheresouth thanks; I'd already read that page, and indeed you can see from the rest of the examples that does indeed work, but it should also work without that according to all I've read, which is frustrating.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • jupyter
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • anitta
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • provamag3
  • tester
  • Leos
  • megavids
  • JUstTest
  • All magazines