J2897

Plotly venv in JupyterLab

Oct 17th, 2022 (edited)
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

Plotly in a virtual environment displaying in JupyterLab.

Install these first...

pip install ipywidgets
pip install jupyter-dash

If you try Plotly in a virtual environment you might only see a blank area...

import plotly.express as px
df = px.data.gapminder().query("country=='Canada'")
fig = px.line(df, x="year", y="lifeExp", title='Life expectancy in Canada', template="plotly_dark")
fig.show()

If you list the extensions, you'll probably find that the Plotly extension isn't installed...

Microsoft Windows [Version 10.0.19044.2130]
(c) Microsoft Corporation. All rights reserved.

C:\Users\J2897>jupyter labextension list
JupyterLab v3.4.8
C:\Users\J2897\AppData\Local\Programs\Python\Python39\share\jupyter\labextensions
        jupyterlab_pygments v0.2.2 enabled ok (python, jupyterlab_pygments)

C:\Users\J2897>

The command to install it is mentioned on the Plotly site...

Microsoft Windows [Version 10.0.19044.2130]
(c) Microsoft Corporation. All rights reserved.

C:\Users\J2897>jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyterlab-plotly
Building jupyterlab assets (production, minimized)
\
C:\Users\J2897>jupyter labextension list
JupyterLab v3.4.8
C:\Users\J2897\AppData\Local\Programs\Python\Python39\share\jupyter\labextensions
        jupyterlab_pygments v0.2.2 enabled ok (python, jupyterlab_pygments)

Other labextensions (built into JupyterLab)
   app dir: C:\Users\J2897\AppData\Local\Programs\Python\Python39\share\jupyter\lab
        @jupyter-widgets/jupyterlab-manager v5.0.3 enabled ok
        jupyterlab-plotly v5.10.0 enabled ok

C:\Users\J2897>
Add Comment
Please, Sign In to add comment