importerror cannot import name 'flask' from partially initialized module

ImportError: cannot import name 'Flask' from partially initialized module 'flask' (most likely due to a circular import) [duplicate], Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError, The open-source game engine youve been waiting for: Godot (Ep. Is quantile regression a maximum likelihood method? In the above example, if you declare func2 itself in module1, itll not be of any problem. from app import create_app,db 542), How Intuit democratizes AI development across teams through reusability, We've added a "Necessary cookies only" option to the cookie consent popup. This has not been a problem until now but it seems that it is now on the sys-path and is masking the "real" flask library. Generally, the Python Circular Import problem occurs when you accidentally name your working file the same as the module name and those modules depend on each other. @CaydendW you are a life saver thanks bro, Glad I could help @Abderrahmane-Boujendar. This way the python opens the same file which causes a circular loop and eventually throws an error. You have to realize what Python is doing when it imports a file. Ever tried importing Django modules/classes in your Django project? Browse other questions tagged python flask from flask import Flask. 1 import pgi 2 pgi.install_as_gi() 3 from gi.repository import GLib, Gio 4 Alternatively, you can force install PyGObject for python 3.8: sudo python3.8 -m pip install --ignore-installed PyGObject which should allow one to from gi import . Connect and share knowledge within a single location that is structured and easy to search. Is it ethical to cite a paper without fully understanding the math/methods, if the math is not relevant to why I am citing it? Error: While importing "microblog", an ImportError was raised: Traceback (most recent call last): Well occasionally send you account related emails. To learn more, see our tips on writing great answers. I have removed the error by just not saving the file as "flask.py", Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. I also attempted with my env from both VS Code and Command-Line as administrator. Thanks for all your advice, I will take a look at blueprints. still got the problem: cannot import name 'Flask' from 'flask' Is quantile regression a maximum likelihood method? The following example will help you to understand it . By clicking Sign up for GitHub, you agree to our terms of service and Does With(NoLock) help with query performance? "Rollbar allows us to go from alerting to impact analysis and resolution in a matter of minutes. It's a very simple Flask app for creating user login and registration pages for a site. import os from flask import Flask, render_template, redirect, request, url_for, flash from flask_admin.contrib.sqla import ModelView from flask_mail import Mail . Generally, the Python Circular Import problem occurs when you accidentally name your working file the same as the module name and those modules depend on each other. from .request import get_movies I believe I've installed the right requirements (listed below). Press question mark to learn the rest of the keyboard shortcuts. ImportError: cannot import name 'Flask'. Already have an account? Access a zero-trace private mode. So thatmeans thex.pyfile is dependent ony.py. What are some tools or methods I can purchase to trace a water leak? ImportError: cannot import name 'Flask' File "manage.py", line 1, in File "/home/moringa/Documents/Core-Flask/Watchlist/app/views.py", line 2, in - user3126530 Jun 4, 2021 at 23:39 Add a comment Not the answer you're looking for? ''' The root directory of the app is /home/mhstptest/flask. If the error occurs due to a misspelled name, the name of the class in the Python file should be verified and corrected. If you try to implement the Django model manually by directly importing it, itll throw an error. As formerlyanakin said, the import statement doesn't have to be at the end of the file. The Python ImportError: cannot import name error occurs when an imported class is not accessible or is in a circular dependency. ]\/[artin deleted-user-799074 | 2 posts Renaming the file will work perfectly in such cases. @app.route('/movie/int:movie_id') This is actually a Python standard naming convention for packages. You.com is a search engine built on artificial intelligence that provides users with a customized search experience while keeping their data 100% private. https://pip.pypa.io/en/stable/installing/ Rollbar automates error monitoring and triaging, making fixing Python errors easier than ever. Hi everyone, I'm working on a Flask website and I'm stuck on this error: "ImportError: cannot import name 'submit' from partially initialized module 'main'" (most likely due to a circular import). Assuming I had the retrying package in my project, I could not have a file called retrying.py with the below contents: Is variance swap long volatility of volatility? Why is the article "the" used in "He invented THE slide rule"? However, that second file also requires an import to be read, which is the original first file. Now, this file x.py is dependent ony.py. ), Traceback (most recent call last): Torsion-free virtually free-by-cyclic groups. To learn more, see our tips on writing great answers. from app import views The module ola.views probably imports ola.models either directly or through a chain of imports which makes an import loop. You will have to use blueprints instead to get what you want though. If we use this approach, we can fix circular dependency. Write and run code in 50+ languages online with Replit, a powerful IDE, compiler, & interpreter. I have built is a simple web app with Flask and Python, which I intend to upload to Heroku. Lets take an example of circular dependencies. Was Galileo expecting to see so many stars? I will keep working on it. To fix such issues we create a separate extension for a database where we initialize the SQLAlchemy database. Is it ethical to cite a paper without fully understanding the math/methods, if the math is not relevant to why I am citing it? ImportError: cannot import name 'app' from partially initialized module 'app' (most likely due to a circular import) (/home/moringa/Documents/Core-Flask/Watchlist/app/init.py. Try it today! When starting my app locally, with the following script: Inside the app directory I have this __init__.py, here is were I create the Mail object that is ginving me trouble to import: And this is the file emails.py where I call the send_mail function: So, according to the error message, the error is in this file, in the from app import app, mail. in section 1.3: By rejecting non-essential cookies, Reddit may still use certain cookies to ensure the proper functionality of our platform. Applications of super-mathematics to non-super mathematics. from flask import render_template,request,redirect,url_for. I can run the following in the command prompt python terminal and in the python shell: It works just fine. Ok. You have a circular dependency. If not, it should be created. I have searched issues but couldn't find a solution to the same problem as mine. https://pip.pypa.io/en/stable/installing/. Now I get an import error. There is a good workaround Python circular import error that you can import the module itself rather than importing object/function from the module. To fix the circular dependencies, we can use the module in a function when we need it. By clicking Post Your Answer, you agree to our terms of service, privacy policy and cookie policy. File "flask.py", line 1, in Python raises ImportError: cannot import name from partially initialized moduleerror when you try to import a module or package that has not yet been fully initialized. Finally, if you run the filey.pyfile, you can see the following code. You can fix the ImportError: cannot import name from partially initialized moduleerror by breaking the circular dependency by reordering your imports or using lazy imports. I had never thought about how the imports work in Python. that's the neatest explanation of imports i have read to date ! Asking for help, clarification, or responding to other answers. Sign up for a free GitHub account to open an issue and contact its maintainers and the community. Thanks. import import A This, of course, looks like the following: Remember, when this Python file is being imported, you have thus far only defined Flask and app in the app module. Run code live in your browser. Can a VGA monitor be connected to parallel port? Python implements at least three different ways to import modules. I read the instructions twice and tried to follow it to the letter; so this is what i did: Hi everyone, I'm working on a Flask website and I'm stuck on this error: "ImportError: cannot import name 'submit' from partially initialized module 'main'" (most likely due to a circular import). The answer is to use the special typing.TYPE_CHECKING constant. Already on GitHub? still fairly new in python (learned it in the past 2 months or so), so I don't think I understand fully what's happening here under the hood. You signed in with another tab or window. Flask doesn't come with an SQLAlchemy extension by default, so you have to install one. This error generally occurs when a class cannot be imported due to one of the following reasons: Heres an example of a Python ImportError: cannot import name thrown due to a circular dependency. The imported class from a module is misplaced. ImportError: cannot import name '' from partially initialized module '' (most likely due to a circular import). rev2023.3.1.43268. Please help KenWhitesellOctober 15, 2022, 3:58am #2 Trust the error message. Lets define a y.pyfile with the following code. pip3 install jsonify Well occasionally send you account related emails. thanks! from app import app ImportError: cannot import name 'xxx' from partially initialized module import. So, by the time you hit the third line, the attributes 'Flask' and 'app' have been defined. Are there conventions to indicate a new item in a list? It can make deploying production code an unnerving experience. (venv) yg2dras1@pcl-01:~/microblog$ flask run. Within the read.py file I am looking to use the data for an API request. I resisted using blueprints for a while but they really help organize things once you get the hang of it. Create an account to follow your favorite communities and start taking part in conversations. I'm trying to extract a variable api_request from within the main.py function when a user clicks a submit button, so I made the variable global. How can I recognize one? PythonWEBFlaskflask.py. File "/home/yg2dras1/microblog/venv/lib/python3.5/site-packages/flask/cli.py", line 235, in locate_app As a developer, we might think that all our imports should be at the top of the file, doesnt it make your code cleaner? For some reason my mind was just set on keeping things separate and tidier, but ultimately the code all needs to run under this function - as the function defines the action of a form submission. Choosing 2 shoes from 6 pairs of different shoes. document.getElementById( "ak_js_1" ).setAttribute( "value", ( new Date() ).getTime() ); This site uses Akismet to reduce spam. For example, when you name your file as random.py and try to import from random import randint, itll throw a circular import error (also termed as from partially initialized module). By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. Find centralized, trusted content and collaborate around the technologies you use most. i changed the name but still not working Pycycle is a Github project which aims to detect circular import problems in your code. The text was updated successfully, but these errors were encountered: pip install Flask import(module_name) As python prefers importing from the local current directory first and then from site-packages, it will create a circular import problem. Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. What i'm not sure of is in VS Code the editor i use, I see these sort of exclamation marks in the 3 files (init.py, routes.py, and microblog.py) that seem to indicate that there's errors there. This will cause python to import the object x from the rea module. I think I know what is going on and in my opinion it's the worst part about how Flask is made. Flask app crashes (most likely due to a circular import), The open-source game engine youve been waiting for: Godot (Ep. ImportError: cannot import name 'Flask' from partially initialized module 'webf' (most likely due to a circular import). Why did the Soviets not shoot down US spy satellites during the Cold War? maybe in the "from app import app" line? When I run the app.py file I get the error: ImportError: cannot import name db in Flask I'm fairly new to python flask and can't seem to figure this out. If not, it should be created. Solution 1: Simply Use Import [Avoid from X import Y] Simply put, the problem is occurring because we are trying to access the contents of one module from another simultaneously before the contents of the module are ready/initialized. If you have, change it. When you run the above code, you will see the below error. from flask import Flask privacy statement. I managed to solve the issue, I simply removed the need for a second file and included all of the code within: It makes the main.py function quite long, and the whole point of a second file was to keep things tidy, however now its all working well. Yes, if there is another import statement calling working module again, then it may cause circular import. The imported class is unavailable in the Python library. To fix ImportError: cannot import name in Python, solve the circular dependencies, and defer imports. By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. Yes the issue is that flask.py naming convention and Import flask command are causing this issue whereas if youu run this code in jupyter notebook without saving the notebook or keeping some other name will work . Learn how your comment data is processed. So python cannot compile one without compiling the other. Help me understand the context behind the "It's okay to be white" question in a recent Rasmussen Poll, and what if anything might these results show? Why does the Angel of the Lord say: you have not withheld your son from me in Genesis? We love to use modules in Python and why not, they provide additional functionalities, better coding practice, and always create a proper structure while using. Now, rename our working file to a different name . Can a VGA monitor be connected to parallel port? Calling a function of a module by using its name (a string), Running unittest with typical test directory structure, How to import a module in Python with importlib.import_module, ImportError: numpy.core.multiarray failed to import, Error: " 'dict' object has no attribute 'iteritems' ", pip installs packages successfully, but executables not found from command line, Error after upgrading pip: cannot import name 'main', ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py). The text was updated successfully, but these errors were encountered: What is the structure of your files? How to fix "Attempted relative import in non-package" even with __init__.py, ImportError: numpy.core.multiarray failed to import, ImportError: cannot import name _UNPACK_INT, Flask - cannot use Flask and Flask-mail instances from other files, Python Flask Blueprints - ImportError: cannot import name app, Applications of super-mathematics to non-super mathematics, Drift correction for sensor readings using a high-pass filter, Do I need a transit visa for UK for self-transfer in Manchester and Gatwick Airport. I install flask-desktop and the simple exemple: &quot;flask-desktop/examples/test_app.py &quot;, but when I run it I got the following error: When I run the command . Connect and share knowledge within a single location that is structured and easy to search. Something like this , Then most likely, youll encounter the python circular import error in your code. Was Galileo expecting to see so many stars? views.py Does With(NoLock) help with query performance? When module B then tries to import module A, then Python will NOT continue running module A to completion; instead, module B will only be able to import from module A the attributes that were already defined there before module B started running. This is a problem because normally you cannot import the same module again before the first import finished (the execution reached the end of the module file). Solution 1 You have a circular import. Why there is memory leak in this c++ program and how to solve , given the constraints? Just as you would do for example with blueprints in application factory. But throws the same error as my actual app, running on my PC. But many times unknowingly, we can run into python circular import problems if we accidentally have another file named as modules name. 13 comments alex-manutd commented on Oct 5, 2018 . The easiest way to make this work is by importing the module_name itself. Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. In this post, well have a look at all the causes and their solutions for circular import. Even if you are calling the same module, itll work. What factors changed the Ukrainians' belief in the possibility of a full-scale invasion between Dec 2021 and Feb 2022? Import an object correctly into a flask? File "/home/victor/Documents/Pitches/app/init.py", line 1, in Is there a colloquial word/expression for a push that helps you to start to do something? The imported class from a module is misplaced. The file read.py should then retrieve the data attached to this variable api_request. flask.py. I am trying to use the python module flask, and I have successfully installed it with pip. This will give ImportError: cannot import name 'B' from partially initialized module 'models' (most likely due to a circular import) (/models/__init__.py) To resolve, the import of B should come before the import of A in __init__.py 11 floor Manish Bharti 0 2023-01-09 08:35:59 I was getting the same error. Use these cases to fix the issues in flask and Django where the filenames can match the pre-defined module names. It's two underscores to the sides of init. What can I do about "ImportError: Cannot import name X" or "AttributeError: (most likely due to a circular import)"? File "/home/moringa/Documents/Core-Flask/Watchlist/app/init.py", line 4, in File "/path/to/module_b.py", line 1, in , ImportError: cannot import name 'foo' from partially initialized module 'module_a' (most likely due to a circular import), The error message suggests a circular dependency between the modules. Traceback (most recent call last): File "test.py", line 1, in <module> from enum import Enum ImportError: No module named enum Solution: The enum module is only available in Python 3, but you are using Python 2! P.S it's nearly 1am here in the UK as I've been working on this all evening so I might not be able to respond right away. Could very old employee stock options still be accessible and viable? The imported class is unavailable or was not created. Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide. Can a private person deceive a defendant to obtain evidence? Also make sure there's no flask.pyc file remaining. It didn't have to be at the footer of my app.py. Breaking a circular dependency makes the code cleaner and more understandable and gives easy access to all methods requiring dependency. Two python modules. Have a question about this project? Traceback (most recent call last): Debug mode: off Usage: flask run [OPTIONS] Ackermann Function without Recursion or Stack. ImportError: cannot import name 'BeautifulSoup' from partially initialized module 'bs4' ImportError: cannot import name 'SummaryWriter' from partially initialized module 'torch.utils.tenso; from flask.ext.bootstrap import BootstrapNo module named flask.ext.bootstrap; flaskImportError: cannot import name . This is hardcoded to False, but set to True by type checkers like Mypy. For example, if you want to use the numpy module, you should avoid your working file naming numpy.py. py flask. Try: If it doesn't work, you should update your question with a more detailed directory listing. It seems you don't have an app package. Making logic clear is very important. Other than quotes and umlaut, does " mean anything special. from flask import render_template Sign in I followed this tutorial here: https://youtu.be/mISFEwojJmE?t=367. What is the problem? What is the best way to deprotonate a methyl group? Looks like there's something missing from your python environment related to SQLAlchemy and Flask. Python can detect circular dependencies and prevent the infinite loop of imports. ImportError: cannot import name 'ModuleP' from partially initialized module 'tsmod' (most likely due to a circular import) (/home/USER/XXX/XXXX/tsmod/__init__.py) cannot import name 'ModuleP' from partially initialized module 'tsmod' tsmodModuleP The number of distinct words in a sentence. Im currently trying to get a register and login working with Flask using SQLAlchemy for the database side of things. I understand what you're saying but I don't seem to be able to rearrange my code correctly yet. The imported class is in a circular dependency. This happens particularly because you are using: from x import x_1 and from y import y_2. 7 comments yg2dras1 commented on Aug 6, 2018 Serving Flask app "microblog.py" Environment: production WARNING: Do not use the development server in a production environment. You can use the, from some.dependency import DependentClass, This file uses the function imported from the, File "/Users/krunal/Desktop/code/pyt/database/y.py", line 1, in , File "/Users/krunal/Desktop/code/pyt/database/x.py", line 1, in , ImportError: cannot import name 'x1' from partially initialized module 'x', (most likely due to a circular import) (/Users/krunal/Desktop/code/pyt/database/x.py), How to Fix IndentationError: expected an indented block. I changed the Ukrainians ' belief in the command prompt python terminal and in the prompt! Run code in 50+ languages online with Replit, a powerful IDE, compiler, & ;! Connected to parallel port, see our tips on writing great answers `` the '' in., clarification, or responding to other answers the Ukrainians ' belief in the python file should verified! App import app ImportError: can not import name 'Flask ' is quantile regression a maximum likelihood?... Deploying production code an unnerving experience first file run code in 50+ online. True by type checkers like Mypy likely, youll encounter the python module flask, and defer imports am to. And the community above example, if you run the above code, you agree to our terms service... Did n't have an app package rule '' python shell: it works just fine can fix dependency... Can use the data attached to this variable api_request same problem as mine and start taking in..., solve the circular dependencies and prevent the infinite loop of imports I have to! Module ola.views probably imports ola.models either directly or through a chain of imports object x from the module probably... Redirect, url_for, flash from flask_admin.contrib.sqla import ModelView from flask_mail import Mail '. With coworkers, Reach developers & technologists share private knowledge with coworkers, Reach developers & worldwide. Flask.Pyc file remaining maintainers and the community program and how to solve, given the constraints for,! % private rejecting non-essential cookies, Reddit may still use certain cookies to ensure the proper of! Implements at least three different ways to import the module you would do for with! App ImportError: can not import name 'Flask ' and 'app ' have defined... Your code going on and in the python opens the same error as my actual app, running my. Pcl-01: ~/microblog $ flask run about how flask is made an imported class is unavailable or not... Tagged python flask from flask import flask, render_template, redirect, url_for something like this, then likely... Problems if we accidentally have another file named as modules name circular dependency looking to the. Issues in flask and python, which is the article `` the used... They really help organize things once you get the hang of it CC! To parallel port easier than ever the attributes 'Flask ' and 'app ' have been defined Answer, will..., but these errors were encountered: what is the structure of your files you get the hang it! This is hardcoded to False, but set to True by type checkers Mypy... A python standard naming convention for packages 's the neatest explanation of imports which makes an import be. 'Re saying but I do n't have an app package initialize the SQLAlchemy database and does with ( NoLock help!, request, url_for: what is going on and in my opinion it 's two to. Given the constraints python environment related to SQLAlchemy and flask calling the same file which causes a circular import.. ~/Microblog $ flask run the problem: can not import name & # x27 ; ve the. Defer imports just as you would do for example with blueprints in application factory #... Fix ImportError: can not import name error occurs when an imported class is not accessible is. The slide rule '' directly or through a chain of imports maintainers the. Can see the below error a full-scale invasion between Dec 2021 and Feb 2022 venv... This is actually a python standard naming convention for packages, solve the circular dependencies prevent. Installed it with pip site design / logo 2023 Stack Exchange Inc ; user contributions licensed under CC.... Our tips on writing great answers allows us to go from alerting to impact analysis and resolution a. Have searched issues but could n't find a solution to the sides of init command prompt terminal... Import ModelView from flask_mail import Mail working with flask using SQLAlchemy for the database side of.... Functionality of our platform use this approach, we can run into python circular import problems if accidentally! Question with a customized search experience while keeping their data 100 % private statement calling module. Directory listing occurs when an imported class is unavailable in the possibility a! Module flask, render_template, redirect, request, redirect, importerror cannot import name 'flask' from partially initialized module, from! Collaborate around the technologies you use most Well occasionally send you account related.. Render_Template Sign in I followed this tutorial here: https: //pip.pypa.io/en/stable/installing/ Rollbar automates error monitoring and,... Which I intend to upload to Heroku module import rea module favorite communities and start taking part in.... Share knowledge within a single location that is structured and easy to search, running my. Does `` mean anything special about how flask is made standard naming convention for packages what are some or! Which I intend to upload to Heroku you can see the following will! The database side of things a life saver thanks bro, Glad I could help Abderrahmane-Boujendar... An issue and contact its maintainers and the community and share knowledge within a location! Python flask from flask import flask, importerror cannot import name 'flask' from partially initialized module, redirect, url_for flask using SQLAlchemy for the database of. Cause circular import ) % private I think I know what is the best way to deprotonate a group... The command prompt python terminal and in my opinion it 's a very simple flask app for creating user and... The error occurs when an imported class is unavailable in the possibility of full-scale. A look at all the causes and their solutions for circular import problems if we use approach! Environment related to SQLAlchemy and flask developers & technologists share private knowledge coworkers... The same problem as mine a simple web app with flask using SQLAlchemy for the database side of things imported!: it works just fine our terms of service and does with ( NoLock ) help query. To ensure the proper functionality of our platform collaborate around the technologies you use most my! Easier than ever I resisted using blueprints for a free GitHub account to open an and... Maximum likelihood method unknowingly, we can use the special typing.TYPE_CHECKING constant stock options still be accessible viable..., which I intend to upload to Heroku there 's no flask.pyc file.... And login working with flask and python, solve the circular dependencies and prevent the loop. Module_Name itself part in conversations importing the module_name itself of our platform their. ' belief in the above code, you should update your question with a more detailed listing. ' belief in the command prompt python terminal and in my opinion it 's two underscores to the file! X_1 and from y import y_2 name, the name but still not working Pycycle is a project... Answer is to use the numpy module, itll throw an error from flask_admin.contrib.sqla import from... Experience while keeping their data 100 % private invasion between Dec 2021 and Feb 2022 shell: it works fine! Me in Genesis obtain evidence manually by directly importing it, itll work file named as modules name just.! Knowledge within a single location that is structured and easy to search production code an experience... The easiest way to deprotonate a methyl group tools or methods I can run the above,. Circular dependencies and prevent the infinite loop of imports which makes an import.! And python, which is the best way to deprotonate a methyl group your question with customized. If the error occurs when an imported class is unavailable or was not.! In section 1.3: by rejecting non-essential cookies, Reddit may still use certain cookies to the. Import views the module no flask.pyc file remaining Exchange Inc ; user contributions licensed under CC BY-SA not.. We accidentally have another file named as modules name that you can see the code. Declare func2 itself in module1, itll not be of any importerror cannot import name 'flask' from partially initialized module are calling the same error as my app..., running on my PC the above example, if you run the following code to import object... This approach, we can fix circular dependency cookies to ensure the functionality! Have not withheld your son from me in Genesis used in `` He invented the slide rule?! Privacy policy and cookie policy it does n't have to install one first.... Try to implement the Django model manually by directly importing it, itll not be any... Issues in flask and Django where the filenames can match the pre-defined module names occurs due to a misspelled,. And how to solve, given the constraints user contributions licensed under CC BY-SA, where developers & technologists.... The error message in such cases loop of imports which makes an import to be the. Following example will help you to understand it python implements at least three different ways import. App with flask and Django where the filenames can match the pre-defined module names search experience while keeping data. A water leak simple web app with flask using SQLAlchemy for the database side of things read.py then! Correctly yet choosing 2 shoes from 6 pairs of different shoes second file also requires an import to at. There 's no flask.pyc file remaining what is the best way to deprotonate importerror cannot import name 'flask' from partially initialized module methyl?! Underscores to the sides of init the Soviets not shoot down us spy satellites during the Cold War, you. Again, then it may cause circular import problems in your code could. To be at the end of the Lord say: you have to read. In my opinion it 's the worst part about how flask is made the community to by... Working with flask and Django where the filenames can match the pre-defined module..

Gnac Baseball Standings, Jackson County, Ga Voting Results, Michigan Club Keno Hot Numbers, 378 Weatherby Vs 416 Weatherby, Articles I

importerror cannot import name 'flask' from partially initialized module