Jupyter Lab controls no longer work ipywidgets with ipympl - matplotlib

I have consistently used the following workflow for fully updating my Jupyter Lab working environments:
$ rmvirtualenv my_env
$ mkvirtualenv --python=`which python` my_env
[my_env] $ pip install -r requirements.txt
[my_env] $ jupyter lab build
[my_env] $ jupyter lab
Recently however, after these steps:
My widgets all become non-functional. I can operate and interact with them, but the figures they control do not change at all.
All of the widget controls move from being above the figure they control to to below it.
Projects in virtualenvs that have not been recently updated in this way continue to work fine, and updating them reliably makes them stop working.
This occurs consistently (I have now ruined half a dozen projects confirming the pattern), and even for notebooks hosted outside my local machine (such as this one hosted on Binder). Control widgets themselves seem to work fine though (e.g., in notebooks like this one) when ipympl is not involved. I have also confirmed that the observed behavior is independent of browser and local machine (at least macOS vs iOS).
Has something about Jupyter Lab, ipywidgets, or ipympl changed recently that might be causing this?
Typical post update (non-working) configuration:
$ jupyter --version
Selected Jupyter core packages...
IPython : 8.4.0
ipykernel : 6.13.1
ipywidgets : 7.7.0
jupyter_client : 7.3.4
jupyter_core : 4.10.0
jupyter_server : 1.17.1
jupyterlab : 3.4.3
nbclient : 0.6.4
nbconvert : 6.5.0
nbformat : 5.4.0
notebook : 6.4.12
qtconsole : not installed
traitlets : 5.2.2
$ jupyter labextension list
JupyterLab v3.4.3
/Users/Rax/Documents/Projects/Coding/Python/venvs/picollisions/share/jupyter/labextensions
jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
nbdime-jupyterlab v2.1.1 enabled OK
jupyter-matplotlib v0.11.1 enabled OK
#jupyterlab/git v0.37.1 enabled OK (python, jupyterlab-git)
#jupyter-widgets/jupyterlab-manager v3.1.0 enabled OK (python, jupyterlab_widgets)
#kiteco/jupyterlab-kite v2.0.2 enabled OK (python, jupyterlab_kite)
Other labextensions (built into JupyterLab)
app dir: /Users/Rax/Documents/Projects/Coding/Python/venvs/picollisions/share/jupyter/lab
Typical pre update (working) configuration:
$ jupyter --version
jupyter core : 4.7.1
jupyter-notebook : 6.4.3
qtconsole : not installed
ipython : 7.26.0
ipykernel : 6.2.0
jupyter client : 6.1.12
jupyter lab : 3.1.10
nbconvert : 6.1.0
ipywidgets : 7.6.4
nbformat : 5.1.3
traitlets : 5.0.5
jupyter labextension list
JupyterLab v3.1.10
/Users/Rax/Documents/Projects/Coding/Python/venvs/picollisions/share/jupyter/labextensions
nbdime-jupyterlab v2.1.0 enabled OK
jupyter-matplotlib v0.9.0 enabled OK
#jupyterlab/git v0.32.2 enabled OK (python, jupyterlab-git)
#jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)
#kiteco/jupyterlab-kite v2.0.2 enabled OK (python, jupyterlab_kite)
/usr/local/share/jupyter/labextensions
jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
Other labextensions (built into JupyterLab)
app dir: /Users/Rax/Documents/Projects/Coding/Python/venvs/picollisions/share/jupyter/lab
Typical requirements:
#...
ipywidgets
ipympl
jupyterlab >=3.1
jupyterlab-git
jupyterlab-kite >=2.0.2
(I've tried omitting Kite to see if that was the culprit. In any case it is not present in the Binder versions.)

Note here, there is bug that is getting sorted.
Options for now:
1
As discussed here if you add fig.canvas.draw() as the last line of plot_logisitic, as suggested by #ianhi here your code will work with the package versions giving you problems.
This approach has the added bonus that is in fact, best practice currently anyway & going forward.
2
Use the older versions if you don't want to add that.
Current launches from here result in that. The versions of the pertinent items where the original code (without addition of fig.canvas.draw()) works is here.

Related

Library not loaded: #rpath/libtbb.dylib in Prophet / Python

I'm on a Mac X1, Monterey.
I've installed prophet and run into this issue when trying to fit a model.
RuntimeError: Error during optimization: console log output:
dyld[90668]: Library not loaded: #rpath/libtbb.dylib
Referenced from: /Users/{username}/opt/anaconda3/lib/python3.9/site-packages/prophet/stan_model/prophet_model.bin
Reason: tried: '/private/var/folders/cd/dfrqgp4s4ll55cwb7rtgccbw0000gq/T/pip-install-rjpuj450/prophet_d7e4cce10e414c89a572fe3605ae9269/build/lib.macosx-11.1-arm64-cpython-39/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib' (no such file), '/private/var/folders/cd/dfrqgp4s4ll55cwb7rtgccbw0000gq/T/pip-install-rjpuj450/prophet_d7e4cce10e414c89a572fe3605ae9269/build/lib.macosx-11.1-arm64-cpython-39/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib' (no such file), '/usr/local/lib/libtbb.dylib' (no such file), '/usr/lib/libtbb.dylib' (no such file)
I know this has to do with the wrong paths being searched. I can find the dylib in
/Users/{user}/opt/anaconda3/lib/python3.9/site-packages/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/
But, it seems prophet doesn't know to look there. I'm curious how I can update/fix either the rpath variable or find another solution?
I tried to create a symbolic link with sudo ln -s, but don't have permissions on the laptop.
TIA!
I got it to work on Apple Silicon (M1 Max in my case) by installing older versions of both pystan and prophet:
pip install pystan==2.19.1.1
pip install prophet==1.0
The other important piece of the puzzle is that you should use Python 3.8 to get it working.
Installing older versions of the libraries and using Python 3.8 are both talked about in issue #2002 on Github, but there's not really an explanation of the libtbb.dylib error message.

Error: Importing notebooks requires Jupyter nbconvert to be installed. Julia

I am trying to export a Julia Jupyter Notebook to pdf
I installed last version of Julia and VS Code (and the Julia and jupyter extension on VS Code)
I can do fine in jupyter notebooks, the code runs and it's saved on .ipynb format.
So this is what i've done:
In the cmd I just put
py -m pip install jupyter
py -m pip install nbconvert
But whenever I try to export the notebook from VS Code I get this error:
Error 2021-10-19 19:25:11: Export failed [Error: Importing notebooks requires Jupyter nbconvert to be installed.
at u.getExportInterpreter (c:\Users\jparedesm\.vscode\extensions\ms-toolsai.jupyter-2021.9.1101343141\out\client\extension.js:37:319922)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async b.export (c:\Users\jparedesm\.vscode\extensions\ms-toolsai.jupyter-2021.9.1101343141\out\client\extension.js:52:919260)
at async g.export (c:\Users\jparedesm\.vscode\extensions\ms-toolsai.jupyter-2021.9.1101343141\out\client\extension.js:37:290037)
at async l._executeContributedCommand (c:\Users\jparedesm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:94:111644)]
Error 2021-10-19 19:25:11: If you have not installed xelatex (TeX) you will need to do so before you can export to PDF, for further instructions go to https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex.
To avoid installing xelatex (TeX) you might want to try exporting to HTML and using your browsers "Print to PDF" feature.
I do have MikTex installed.
So I don't know what is going on.
Please, let me know how to export a jupyter notebook.
This is what the notebook looks like:
I have a similar problem than yours. The only difference, as I can guess, is that I'm using Mac and have TeXShop instead of MikTex. I have compiled .tex files using xelatex, so I think we both need to tell Visual Studio Code where is the xelatex file. I did a bit of research on the Internet and find suggestions to install the LaTex Workshop extension on VSC. It didn't solve the problem for me, but it'd work for you. I hope so. Let me know in that case.
Best,

pandas not works for django?

I saw the first rocket.
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world.")
'Hello, world.' it's ok!
also 'python manage.py migrate' ok.
But when I import pandas...
(import only and no use.)
from django.http import HttpResponse
import pandas as pd
def index(request):
return HttpResponse("Hello, world.")
Browser thinks forever.
How can I fix this issue?
my environment
OS: CentOS Linux release 7.7.1908 (Core)
Pandas: 0.19.2
Apache: 2.4.6 (CentOS)
Django: 2.1
Browser: Google Chrome 76.0.3809.132
# python --version
Python 3.6.0 :: Anaconda 4.3.1 (64-bit)
simply, Anaconda is older?
Please let me know if there is any missing information.
Progress after that. Tried "Panda" update.
#Conda installs panda
I was able to clear the browser thinking during the import error.
I will re-install Newest Anaconda.
(_mysql_exceptions.OperationalError) (2006, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)") (Background on this error at: sqlalche.me/e/e3q8)
Currently, if you don't use django, you can execute SQL from py file to MySQL.
The situation has improved. It hasn't been resolved yet, but the error has changed this morning. I will challenge again when the work is over.
Settled! I think anaconda was old. Speaking of which, it took about two years to build a VPS, and anaconda was the version at that time.

Cannot find module PIL in Python

I am using:
Thonny Version 3.2.1
Python Version 3.7.0
PIP Version 19.2.3
Pillow Version 6.1.0
I am trying to import an image into my program and show it on the screen with the below code:
I get the error:
ModuleNotFoundError: No module named 'PIL'
backend.py, line 276
I believe the problem isn't my code, but instead an issue with the module Pillow not being found by Python?
Can anyone please help with a fix? I can clarify any info needed.
Additionally, I am new to Python and so go easy on me :-) Apologies if any of my terminology is incorrect.
I have tried:
1\ Removing PIL as per the install warning from Pillow (PIL Fork) install info. It was not present on my system. I did this through CMD.
2\ I always access CMD as the administrator.
3\ Updating all program versions above through CMD.
4\ Info I’ve found shows the above versions are compatible.
5\ Using the code help('modules') to show available modules, it does not show 'PIL' or 'Image', but does show 'pip'.
6\ Checked many forums for other fixes.
from PIL import Image
im = Image.open("JC.png")
im.show()

Missing package to enable rendering OpenAI Gym in Colab

I'm attempting to render OpenAI Gym environments in Colab via a Mac using the StarAI code referenced in previous questions on this topic. However, it fails. The key error (at least the first error) is shown in full below, but the import part seems to be "Please install xdpyinfo!"
PyPI doesn't have xdpyinfo. What is it and how do I install it?
Full error message:
482780428160 abstractdisplay.py:151] xdpyinfo was not found, X start can not be checked! Please install xdpyinfo!
I've seen the same error, and solved it by installing x11-utils package which includes xdpyinfo command.
!apt-get install x11-utils