'flask application not running [duplicate]

from flask import Flask
app=Flask(__name__)
@app.route('/admin')
def admin():
return "the current user is admin"

@app.route('/student')
def student():
  return "the current user is student"

@app.route('/teacher')
def teacher():
  return "the current user is teacher"

@app.route('/user/<name>')
def user(name):
  if name == 'admin':
     return redirect(url_for('admin'))
  if user == 'student':
     return redirect(url_for('student'))
  if user == 'teacher':
     return redirect(url_for('teacher'))
if _name_=='_maiin_':
  app.run(debug=true)

this is the flask code am trying to execute.showing me error of-

  File "C:\Users\Nitish Phutane\Desktop\flask.py", line 1, in <module>
    from flask import Flask
  File "C:\Users\Nitish Phutane\Desktop\flask.py", line 1, in <module>
    from flask import Flask
ImportError: cannot import name 'Flask' from partially initialized module 'flask' (most likely due to a circular import) (C:\Users\Nitish Phutane\Desktop\flask.py)

though i have install flask on my system too.can someone please help me to run this code.



Solution 1:[1]

You have a circular import because your file in named flask.py. Change this to anything else and the problem will be gone.

Solution 2:[2]

I think you have created a file called flask.py, so now it is trying to import Flask module from your own file. Try renaming that file in desktop to something else and try again. It is called circular import, and you should always prevent it from happening.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Phantoms
Solution 2 Anish Shilpakar