Forums

ModuleNotFoundError: No module named 'flask_migrate'

Hello everybody.
I'm stuck at the flask mega tutorial in chapter 4.

Because I'm paranoid, I already changed all my .py-files to the ones provided from the author via github, so there should be no errors in my code.

I also worked through the goolge results in this forum, but nothing seems to help.
I also followed along this help-page and everything seemed fine:
https://help.pythonanywhere.com/pages/DebuggingImportError/

I get this error and dont know how to fix it:

2020-03-18 15:36:22,385: Error running WSGI application
2020-03-18 15:36:22,503: ModuleNotFoundError: No module named 'flask_migrate'
2020-03-18 15:36:22,504:   File "/var/www/devfabi_pythonanywhere_com_wsgi.py", line 19, in <module>
2020-03-18 15:36:22,504:     from microblog import app as application  # noqa
2020-03-18 15:36:22,504: 
2020-03-18 15:36:22,504:   File "./microblog.py", line 1, in <module>
2020-03-18 15:36:22,504:     from app import app, db
2020-03-18 15:36:22,504: 
2020-03-18 15:36:22,504:   File "./app/__init__.py", line 3, in <module>
2020-03-18 15:36:22,504:     from flask_migrate import Migrate
2020-03-18 15:36:22,504: ***************************************************
2020-03-18 15:36:22,505: If you're seeing an import error and don't know why,
2020-03-18 15:36:22,505: we have a dedicated help page to help you debug: 
2020-03-18 15:36:22,505: https://help.pythonanywhere.com/pages/DebuggingImportError/
2020-03-18 15:36:22,505: ***************************************************
2020-03-18 15:36:23,767: Error running WSGI application
2020-03-18 15:36:23,768: ModuleNotFoundError: No module named 'flask_migrate'
2020-03-18 15:36:23,768:   File "/var/www/devfabi_pythonanywhere_com_wsgi.py", line 19, in <module>
2020-03-18 15:36:23,768:     from microblog import app as application  # noqa
2020-03-18 15:36:23,768: 
2020-03-18 15:36:23,768:   File "./microblog.py", line 1, in <module>
2020-03-18 15:36:23,768:     from app import app, db
2020-03-18 15:36:23,768: 
2020-03-18 15:36:23,769:   File "./app/__init__.py", line 3, in <module>
2020-03-18 15:36:23,769:     from flask_migrate import Migrate
2020-03-18 15:36:23,769: ***************************************************
2020-03-18 15:36:23,769: If you're seeing an import error and don't know why,
2020-03-18 15:36:23,769: we have a dedicated help page to help you debug: 
2020-03-18 15:36:23,769: https://help.pythonanywhere.com/pages/DebuggingImportError/
2020-03-18 15:36:23,769: ***************************************************

Okay, I am indeed stupid.
For future reference: I forgot to set up the virtualenv in the web tab.

which pip

shows you where it is located. read the WHOLE documentation and help pages before asking stupid questions, like I just did.
Sorry

No problem. We're glad you solved it.

I don't get it I have that same error since I am done with half of Flask Mega Tutorial but am trying to get the code worldwide on a proper website and easy so can you please explain the virtual environment thing better?

first thing to check: are you / is Flask Mega Tutorial using a virtualenv?

second thing to check: where is your virtualenv on PythonAnywhere, and what python version are you running on PythonAnywhere

third thing to check: what is the command you used to install everything?

My flask project isn't built on a virtualenv, and am getting a similar error. Could this be the reason ?

If it's not using a virtualenv, you probably just need to install the module. So, for example, if you're running your website against Python 3.8, you would run:

pip3.8 install --user flask_migrate

...in bash.

Hi I am new to python anywhere and in my error log It can see flask_migrate but it's right there

2022-08-25 08:33:30,424: Error running WSGI application
2022-08-25 08:33:30,425: ModuleNotFoundError: No module named 'flask_migrate'
2022-08-25 08:33:30,425:   File "/var/www/steal_pythonanywhere_com_wsgi.py", line 111, in <module>
2022-08-25 08:33:30,425:     from steal import stealapp as application  # noq
2022-08-25 08:33:30,425: 
2022-08-25 08:33:30,425:   File "/home/steal/steal/steal.py", line 1, in <module>
2022-08-25 08:33:30,426:     from stealapp import app
2022-08-25 08:33:30,426: 
2022-08-25 08:33:30,426:   File "/home/steal/steal/stealapp/__init__.py", line 4, in <module>
2022-08-25 08:33:30,426:     from flask_migrate import Migrate
2022-08-25 08:33:30,426:

[edit by admin: formatting]

I see that your website is using a virtualenv. Are you sure you've installed flask_migrate into that env? You can list the installed packages by starting a bash console inside the env from the "Web" page, and then running pip freeze.