Home > Back-end >  how to fix matplotlip invalid syntax error?
how to fix matplotlip invalid syntax error?

Time:05-21

i'm trying to run this simple code but keep facing with this error. i've downloaded everything and searched everywhere but still don't know how to handle this.

from matplotlib import pyplot as plt 
plt.plot([1,2,3,4])
plt.show()

and this is the error :

Traceback (most recent call last):
  File "C:\Users\TWINS PC\Desktop\test1.py", line 1, in <module>
    from matplotlib import pyplot as plt
  File "C:\Users\TWINS PC\Desktop\matplotlib.py", line 1
    Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
             ^
SyntaxError: invalid syntax

CodePudding user response:

Your code works i tested it. try to import matplotlib in this way:

import matplotlib.pyplot as plt
  • Related