1

My Jupyter notebook is displaying text rather than ipywidgets. Here is a screenshot:

enter image description here

I read several posts about similar problems, like this one: Jupyter Notebook not rendering ipywidgets. Most of them indicate that the solution is to enable an extension, e.g: https://stackoverflow.com/a/38001920/11692496 But it seems to apply to older version of jupyter notebooks. I tried it anyway (with the --sys-prefix argument, which is required for virtualenv), but it didn't fix it.

I'm working with a jupyter notebook and a virtualenv. Just to be sure, I created a fresh venv and installed the minimal packages. No luck.

I'm using Python 3.10.6 and here is my versions list:

enter image description here

Thanks for your help!

Gwalchaved
  • 37
  • 9
  • @Wayne Yes I tried with --sys-prefix, I noted that it was required for virtualenv. I edited my question to add it. Thanks for your interest. – Gwalchaved Oct 20 '22 at 16:19
  • It looks like order can matter when using environments. See [here](https://ipywidgets.readthedocs.io/en/latest/user_install.html#installing-in-classic-jupyter-notebook). Did you try the pip install again after installing widgetsnbextension and enabling it? – Wayne Oct 20 '22 at 16:21
  • mmh, actually I think that I just ran 'pip install jupyter notebook' and let it install all the packages for me. So I installed the extension after that. I'll try to install the extension before the rest and tell you. – Gwalchaved Oct 20 '22 at 16:25
  • Aside... do you need to do some major developing using ipywidgets or just looking to try some stuff. I can direct you to where you could try it in your browser via a remote, temporary session or using JupyterLite (ipywidgets supposedly work there now) inside your browser's web assembly handling ability. – Wayne Oct 20 '22 at 16:26
  • I definitely use it the second way, for visualizing finance data. I developed two sets of widgets: one to load data with some parameters, and one to control the view (like adding/removing scatters, navigate in time, change time span and so on). But I still used Pycharm to develop these controls and I import the code into the Jupyter notebook. I have very few lines in the cells. I find it easier to debug. If you have advice regarding this, the amateur I am will be glad to read! – Gwalchaved Oct 20 '22 at 16:38
  • Hmm... if your finance data is large stuff it may not be sufficient to use the temporary sessions. But who knows. It could save you sorting out your system right now if everything else is good. For temporary sessions on a remote system where it will work, go [here](https://github.com/fomightez/3Dscatter_plot-binder) and click on `launch binder`. A session will spin up. It starts in the classic notebook interface. To make it easy to add your data file, you can click on the Jupyter icon in the upper left to switch to JupyterLab & then can drag files from your local machine into the file ... – Wayne Oct 20 '22 at 16:45
  • browser panel on the left side and drop them. (You can add your notebooks that way, too.) You can always switch back to the classic notebook interface from under 'Help' > 'Launch Classic Notebook'. IPywidgets work in either interface there. Remember to download anything useful you make ASAP as it will time out after inactivity. – Wayne Oct 20 '22 at 16:48
  • To try in JupyterLite, go [here](https://jupyterlite.readthedocs.io/en/latest/) and click on the orange buttons 'Lab' or 'Retro' in the upper corner to get the interface your prefer. 'Retro' is more like the classic document-centric notebook experience. (You can always switch back from JupyterLab the same way as a I described above so I always start in JupyterLab.) When JupyterLite opens, you'll see a directory called `pyolite`. Click on it to open it and then choose `interactive-widgets.ipynb` and you'll see you can run that and ipywidgets works. JupyterLite is running inside your own .... – Wayne Oct 20 '22 at 16:52
  • I'll definitely check this out. In the meantime, I tried what you suggested (pip install again after enabling the extension), but it didn't work. Thanks again. – Gwalchaved Oct 20 '22 at 16:55
  • browser using web assembly. Only the static files are being served from the originating site. So nothing in this case leaves your computer; however, because the web assembly 'machine' is running inside a sandbox in your browser, you have to sort of put stuff in and out similar to as if it was running remote. However, it will be pretty persistent (unlike mybinder-based stuff) as long as you don't clear your browser cache or trash your browser. So in a way it is best to treat it as sort of temporary and don't rely on the **internal browser storage** as a way to save your efforts. – Wayne Oct 20 '22 at 16:56
  • Sorry to hear trying the order like the documentation suggests didn't help. If you were really new, I'd just suggest installing the Anaconda distribution as I think it comes with things set up more easily. However, it sounds like you do a fair amount of development already and it may cause you more headaches than it is worth just to get ipywidgets rendering on your local machine. – Wayne Oct 20 '22 at 16:59

1 Answers1

0

For the record, I didn't manage to solve this issue on my virtualenv.

As @Wayne suggested above, I went for a workaround, namely a docker container based on jupyter/tensorflow-notebook

Gwalchaved
  • 37
  • 9