Type Error 'module' object is not callable

I was trying to use plotly to create scatter plots and Type error occurs.
Could someone gimme a solution for this issue as soon as possible ?

import numpy as np
import pandas as pd
import cufflinks as cf
import plotly as py
import plotly.tools as tls
import plotly.graph_objs as go

a = np.linspace( start = 0, stop = 36, num = 36)
b= np.random.uniform( low = 0.0, high = 1.0, size = 36 )
trace = go.scatter(x=a, y=b)
data = [trace]
py.iplot(data, filename= ‘basic’)

TypeError Traceback (most recent call last)
2 np.random.seed(25)
3 b= np.random.uniform( low = 0.0, high = 1.0, size = 36 )
----> 4 trace = go.scatter(x=a, y=b)
5 data = [trace]
6 py.iplot(data, filename= ‘basic’)

TypeError: ‘module’ object is not callable

You need to call go.Scatter and not go.scatter (please see https://plot.ly/python/line-and-scatter/)

1 Like

Also, please consider upgrading to a more recent version of plotly, the py.iplot syntax is not valid any more in plotly 4+.

Yeah ! My next error is that.
How can I correct that ?
module ‘plotly’ has no attribute ‘iplot’
Should I import cufflinks ?

No need for cufflinks here, please use the same syntax as in https://plot.ly/python/line-and-scatter/#simple-scatter-plot (or consider using plotly express as in https://plot.ly/python/line-and-scatter/#scatter-plot-with-plotly-express)

1 Like

Thank you so much Emmanuelle !