简体   繁体   中英

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. I have installed the Python 3 version. I am also using a Mac if that matters. I tried a variety of commands in the terminal but none of them worked.

This is my command in 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'

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

在此处输入图片说明

Official documentation page says:

For use in the classic Jupyter Notebook, install the notebook and ipywidgets packages using pip...

$ 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 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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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