1

I tried to run this code in spyder IDE of anaconda but it's not working

import matplotlib.pyplot as plt
plt.plot([1,2,3,4,5],[1,4,9,16,25])
plt.show()

The above code is returning error as follows: TypeError: 'tuple' object is not callable

I am not able to figure out the problem.Please help

Aarish
  • 11
  • 2
  • Could you include the complete error traceback in your question? – 9769953 Aug 11 '18 at 11:39
  • https://stackoverflow.com/questions/22762481/tuple-is-not-callable-in-python this may be related, can't tell without you posting more of the error. – Zain Patel Aug 11 '18 at 11:52
  • Try `print(plt.plot)`. If it says `tuple` then you've accidentally assigned the function name to a `tuple`. You need to reload the library or restart your kernel. – pault Aug 11 '18 at 11:55
  • Possible duplicate of ['Tuple is not callable' in Python](https://stackoverflow.com/questions/22762481/tuple-is-not-callable-in-python) – pault Aug 11 '18 at 11:57
  • Possible duplicate of [Builtin function not working with Spyder](https://stackoverflow.com/questions/47738537/builtin-function-not-working-with-spyder) – roganjosh Aug 11 '18 at 12:19
  • Ok, it's not a builtin but I'm 99.9% confident that it's the same issue. I also link to a way how to stop this happening in my answer. – roganjosh Aug 11 '18 at 12:20

1 Answers1

0

Not sure if this applies here but I had similar issues with matplotlib. From another Stackoverflow-answer this suggestion helped me:

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

As said in the comments: the full error would help figuring out what really goes wrong.

Vasilis G.
  • 7,556
  • 4
  • 19
  • 29
Gegenwind
  • 1,388
  • 1
  • 17
  • 27