简体   繁体   English

如何为 Python 3 Jupyter Notebook 安装 Plotly?

[英]How to install Plotly for Python 3 Jupyter Notebook?

I'm a total beginner and I have a problem installing plotly to use it in my Jupyter Notebook.我是一个完全的初学者,我在安装 plotly 以在我的 Jupyter Notebook 中使用它时遇到了问题。 I have installed the Python 3 version.我已经安装了 Python 3 版本。 I am also using a Mac if that matters.如果这很重要,我也在使用 Mac。 I tried a variety of commands in the terminal but none of them worked.我在终端中尝试了各种命令,但没有一个起作用。

This is my command in Jupyter Notebook:这是我在 Jupyter Notebook 中的命令:

from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot

print(__version__) # requires version >= 1.9.0

This is the error I get:这是我得到的错误:

ModuleNotFoundError: No module named 'plotly' ModuleNotFoundError:没有名为“plotly”的模块

I would really appreciate some help!我真的很感激一些帮助! Thanks in advance.提前致谢。 Desperate beginner绝望的初学者

I have now solved the problem.我现在已经解决了这个问题。 I just opened a new Terminal and made sure that I wrote the command我刚刚打开了一个新终端并确保我编写了命令

pip install cufflinks

directly after the second line.直接在第二行之后。

The same worked for同样适用于

pip install plotly

在此处输入图片说明

Download whl file: https://files.pythonhosted.org/packages/3e/77/905effe9361395d3e094ffd2b54b4085d339a7b7de9c2c91fa55ec257422/plotly-3.5.0-py2.py3-none-any.whl下载whl文件: https ://files.pythonhosted.org/packages/3e/77/905effe9361395d3e094ffd2b54b4085d339a7b7de9c2c91fa55ec257422/plotly-3.5.0-py2.py3whlnone-

use pip install C:\\Users\\Downloads\\plotly-3.5.0-py2.py3-none-any.whl使用pip install C:\\Users\\Downloads\\plotly-3.5.0-py2.py3-none-any.whl

Official documentation page says:官方文档页面说:

For use in the classic Jupyter Notebook, install the notebook and ipywidgets packages using pip...要在经典的 Jupyter Notebook 中使用,请使用 pip 安装notebookipywidgets包...

$ pip install "notebook>=5.3" "ipywidgets>=7.2"

or conda.或康达。

$ conda install "notebook>=5.3" "ipywidgets>=7.2"

These packages contain everything you need to run a Jupyter notebook...这些包包含运行 Jupyter 笔记本所需的一切......

$ jupyter notebook

Display plotly figures inline using the notebook renderer...使用笔记本渲染器内联显示绘图图形...

import plotly.graph_objects as go
fig = go.Figure(data=go.Bar(y=[2, 3, 1]))
fig.show()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM