Trouble with importing plotly in Jupyter notebook


#1

I’ve went through the directions for the installation of plotly found on the site (i.e pip install plotly) etc. but I’m still having issues. I’m trying to run Jupyter notebook and use plotly within Jupyter notebook. I’m using the free version of plotly, and it is my understanding that I have to use plotly in the offline mode.

When I try to import in J Notebook, I get this error:

50%20PM

What should I be doing to be able to run plotly? Not sure if it’s relevant, but I launch J Notebook through terminal/localhost. Also, I’ve checked to see if plotly is installed and it is on my device.


#2

Hey @gumesh

After following the instruction here https://plot.ly/python/getting-started/#installation try the below:

import plotly
import plotly.graph_objs as go

plotly.__version__

plotly.offline.init_notebook_mode(connected=True)

data = [
    go.Scatter(
        x=[1,2,3,4],
        y=[1,2,3,4],
    )
]

layout = go.Layout(
    title='testing'
)

fig = go.Figure(data=data,layout=layout)
plotly.offline.iplot(fig)

#3

Hi, thanks for the response. I actually figured it out. My issue was that I wasn’t loading my username and API key properly, and also I had to do import plotly.plotly for it to work.

Thanks for all the help!