Closed kapoorkaran closed 4 years ago
@kapoorkaran it appears you have a space before microblog in your FLASK_APP
variable. Make sure that space is removed when you set this environment variable.
Also, you seem to be in the app directory. You should be in the microblog directory, and microblog.py should be there as well, not inside app.
I have a similar error. Please let me know what im doing wrong. Thanks!
(venv) Thomass-MacBook-Air:microblog thomasjoy$ flask run
Error: Could not import "microblog".
@tomjjoy do you have a microblog.py file in the current directory?
I see exactly the same issue too. I do have the microblog.py file in the current directory.
(venv) C:\Users\nagar\Desktop\microblog>flask run
Error: Could not import "microblog".
Wonder if this has got anything to do with the Flask Version I'm using. I have Flask 1.0.2
@nagarajnms open a python shell (just type python
) and then enter import microblog
in the prompt. Do you get any errors?
Hey @miguelgrinberg , I figured out the error or rather the mistake I did. :) I Had the microblog.py inside the app package. I brought it one level up and the issue got fixed.! Thanks.
Hey @miguelgrinberg , I figured out the error or rather the mistake I did. :) I Had the microblog.py inside the app package. I brought it one level up and the issue got fixed.! Thanks.
This worked!
Hey @miguelgrinberg , I figured out the error or rather the mistake I did. :) I Had the microblog.py inside the app package. I brought it one level up and the issue got fixed.! Thanks.
For those that still did not understand the solution being mentioned here, he meant put your microblog.py in your microblog folder or directory not in the app directory. Move the microblog.py file from the app directory to the microblog directory.
@nagarajnms and anyone that is exploring flask newly like me. Let's communicate and build together using the microblog as a starting point. You can Dm me via twitter:@MaestroAby
!Thanks to the developer! Error: Usage: flask db init [OPTIONS] Error: Could not import "microblog".
解决方法: 给英文不好的朋友留下一个解决方法,【flask db init】这个指令需要在你的项目的根目录下运行,例如你的项目路径是 【C:/migrations】,而你的终端开启的时候路径默认是【C:/】你就需要使用CD migrations进入它根目录来运行该指令
set FLASK_ENV=development if this problem still exists try the above method, including all other answers . It worked for me
Hey @miguelgrinberg , I figured out the error or rather the mistake I did. :) I Had the microblog.py inside the app package. I brought it one level up and the issue got fixed.! Thanks.
thanks it worked !!
I have this problem as well. My react project contains api-rest folder for the backend. But Heroku scresms: Error: Could not import "api".
@saraems your api-rest
folder needs to be in the Python import path. Did you set this up?
Hm, well yes. But I am not sure if they are in a conflict Dockerfile vs .flaskenv. It works locally with no issues.
@saraems This is on Heroku, right? Then the Dockerfile and .flaskenv have nothing to do with it, what matters is what's on your Procfile, which I assume has a gunicorn command? You really haven't answered my question. You have your main Flask file in a sub-directory. Have you configured Python to have that sub-directory in the import path? If you didn't, then import api
is not going to work.
I think I didn't answer you @miguelgrinberg because I didn't understand the question.
Yes, I am trying to deploy on Heroku.
My Procfile: web: gunicorn api:app
Is is the configuration for Python heroku config:add PYTHONPATH=api-rest
? If so I just added. Or it's something else ?
Ok. Heroku sees my api.py
now. I still have some troubles with PORT Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
. Thank you @miguelgrinberg I've been struggling with that since last week.
Hi Can you help me with the following C:\Users\KaranKapoor\Desktop\microblog\app>flask run
Error: Could not import "app. microblog".