以下代码在木星实验室中不呈现:
%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')

我尝试安装这里提到的所有依赖项和扩展( https://plot.ly/python/getting-started/#jupyterlab-support-python-35 )
还有这里的步骤-- 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编辑:
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发布于 2019-08-11 17:47:44
编辑:这些说明和更多现在在我们的官方故障排除指南!
可能是以前安装的残余物或安装企图造成了问题。我建议要么从干净的安装开始,要么卸载所有Plotly模块(从pip和conda!)和与jlab相关的扩展,然后遵循以下说明: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发布于 2021-01-29 11:16:51
按照官方的plotly.py repo https://github.com/plotly/plotly.py,为了在JupyterLab中正确地呈现特定的扩展,需要通过命令安装特殊的扩展
jupyter labextension install jupyterlab-plotly@4.14.3发布于 2021-06-05 19:25:00
我遇到了同样的问题,但原因不同,需要不同的解决方案。只是想跟遇到同样问题的人分享一下。
我在一个没有安装nodejs或npm的Docker容器中运行jupyterlab。
我无法通过以下方式安装所需的分机:
jupyter labextension install jupyterlab-plotly因为它给了我这个错误:
ValueError: Please install nodejs and npm before continuing installation. nodejs may be installed using conda or directly from the nodejs website.Conda在容器上不可用,当通过jupyterlab终端(通过pip或apt-get)安装节点和npm时,我得到了相同的错误,或者版本错配(当使用apt-get时,我得到的nodejs版本太旧了)。
以下步骤帮助我解决了这个问题。
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bashSHELL ["bash", "-lc"] <--仅当容器已经不使用bash作为shell时才有必要RUN export NVM_DIR="$HOME/.nvm"RUN [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvmRUN [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completionRUN nvm install 14.17.0RUN jupyter labextension install jupyterlab-plotly重新启动内核并进行愉快的绘图;)
您还可以考虑安装conda,然后通过conda安装nodejs,如果这对您的用例有意义的话。不过,我还没有测试这是否有效。
https://stackoverflow.com/questions/57450868
复制相似问题