Jupyter Lab 中未渲染 Plotly Express

2024-05-14

以下代码不会在 Jupyter 实验室中呈现:

%matplotlib widget
import plotly.express as px  
import numpy as np 
import pandas as pd

df = pd.DataFrame(np.random.randint(0,100,size=(5, 4)), columns=list('ABCD'))
px.bar(df, x='A', y='B')

enter image description here I have tried to install all the dependencies and extensions mentioned in here https://plot.ly/python/getting-started/#jupyterlab-support-python-35 https://plot.ly/python/getting-started/#jupyterlab-support-python-35

还有这里的步骤https://github.com/matplotlib/jupyter-matplotlib https://github.com/matplotlib/jupyter-matplotlib

没有任何作用

这是我的设置:

jupyter lab --version
1.0.2

python --version
Python 3.6.1 :: Continuum Analytics, Inc.

conda list jupyterlab
# packages in environment at C:\Users\***\Anaconda3:
#
# Name                    Version                   Build  Channel
jupyterlab                1.0.2            py36hf63ae98_0
jupyterlab_launcher       0.13.1                   py36_0
jupyterlab_server         1.0.0                      py_0

conda list nodejs
# packages in environment at C:\Users\***\Anaconda3:
#
# Name                    Version                   Build  Channel
nodejs                    0.1.1                    pypi_0    pypi

conda list plotly
# packages in environment at C:\Users\***\Anaconda3:
#
# Name                    Version                   Build  Channel
plotly                    4.1.0                    pypi_0    pypi
plotly-express            0.4.1                    pypi_0    pypi

EDIT:

jupyter-labextension list
JupyterLab v1.0.2
Known labextensions:
   app dir: C:\Users\***\Anaconda3\share\jupyter\lab
        @jupyter-widgets/jupyterlab-manager v1.0.2 enabled  ok
        @jupyterlab/git v0.8.0 enabled  ok
        @jupyterlab/plotly-extension v1.0.0 enabled  ok
        jupyter-matplotlib v0.4.2 enabled  ok
        jupyterlab-chart-editor v1.2.0 enabled  ok
        jupyterlab-plotly v1.1.0 enabled  ok
        plotlywidget v1.1.0 enabled  ok

编辑:这些说明和更多内容现已在我们的官方中故障排除指南 https://plot.ly/python/troubleshooting/!

可能是先前安装的残留或安装尝试导致了问题。我建议从全新安装开始,或者卸载所有 Plotly 模块(来自 pip 和 conda!)以及与plotly 相关的 jlab 扩展,然后按照此处的说明进行操作:https://plot.ly/python/getting-started/ https://plot.ly/python/getting-started/

卸载模块的问题是

conda uninstall plotly
pip uninstall plotly

然后根据上面链接的说明重新安装其中之一,但不能同时重新安装两者。

卸载 JupyterLab 扩展的方法是

jupyter labextension uninstall @jupyterlab/plotly-extension
jupyter labextension uninstall jupyterlab-plotly 
jupyter labextension uninstall plotlywidget
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Jupyter Lab 中未渲染 Plotly Express 的相关文章

随机推荐