Skip to content Skip to sidebar Skip to footer

Can Not Import Flask Pycharm

from flask import Flask app = Flask(__main__) if __name__ == '__main__': app.run() If i run this i get the following error code: ImportError: cannot import name 'Flask' from

Solution 1:

you are facing this issue because of circular import.

When Python imports a module, it checks the module registry to see if the module was already imported. If the module was already registered, Python uses that existing object from cache. The module registry is a table of modules that have been initialized and indexed by module name. This table can be accessed through sys.modules.

If it was not registered, Python finds the module, initializes it if necessary, and executes it in the new module's namespace.

In your case you are importing module flask in a script named flask. renaming the file name should resolve your issue.

to know more about circular import you can read the article:

https://stackabuse.com/python-circular-imports/

https://www.stefaanlippens.net/circular-imports-type-hints-python.html

Post a Comment for "Can Not Import Flask Pycharm"