0

I need help understanding whats wrong here.

I will try to explain this as best I can, but Im a bit new to PythonAnywhere. I get this error:

Traceback (most recent call last):
  File "/home/HelliottChip/mysite/app/__init__.py", line 6, in <module>
    from flask_migrate import Migrate
ModuleNotFoundError: No module named 'flask_migrate'

When trying to run my main.py file. But i have them all installed as shown in this code:

17:14 ~/.local/bin $ pip install Flask-SQLAlchemy email_validator flask-mail pyjwt flask-bootstrap flask-moment                                                                                                  
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2
.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support                                                                      
Looking in links: /usr/share/pip-wheels                                                                                                                                                                          
Requirement already satisfied: Flask-SQLAlchemy in /usr/local/lib/python2.7/dist-packages (2.4.1)                                                                                                                
Requirement already satisfied: email_validator in /home/HelliottChip/.local/lib/python2.7/site-packages (1.1.2)                                                                                                  
Requirement already satisfied: flask-mail in /usr/local/lib/python2.7/dist-packages (0.9.1)                                                                                                                      
Requirement already satisfied: pyjwt in /usr/local/lib/python2.7/dist-packages (1.7.1)                                                                                                                           
Requirement already satisfied: flask-bootstrap in /usr/local/lib/python2.7/dist-packages (3.3.7.1)                                                                                                               
Requirement already satisfied: flask-moment in /home/HelliottChip/.local/lib/python2.7/site-packages (0.11.0)                                                                                                    
Requirement already satisfied: Flask>=0.10 in /usr/local/lib/python2.7/dist-packages (from Flask-SQLAlchemy) (1.1.1)                                                                                             
Requirement already satisfied: SQLAlchemy>=0.8.0 in /usr/local/lib/python2.7/dist-packages (from Flask-SQLAlchemy) (1.3.10)                                                                                      
Requirement already satisfied: idna>=2.0.0 in /usr/local/lib/python2.7/dist-packages (from email_validator) (2.8)                                                                                                
Requirement already satisfied: dnspython>=1.15.0 in /home/HelliottChip/.local/lib/python2.7/site-packages (from email_validator) (1.16.0)                                                                        
Requirement already satisfied: blinker in /usr/local/lib/python2.7/dist-packages (from flask-mail) (1.4)                                                                                                         
Requirement already satisfied: dominate in /usr/local/lib/python2.7/dist-packages (from flask-bootstrap) (2.4.0)                                                                                                 
Requirement already satisfied: visitor in /usr/local/lib/python2.7/dist-packages (from flask-bootstrap) (0.1.3)                                                                                                  
Requirement already satisfied: itsdangerous>=0.24 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.10->Flask-SQLAlchemy) (1.1.0)                                                                         
Requirement already satisfied: Jinja2>=2.10.1 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.10->Flask-SQLAlchemy) (2.10.3)                                                                            
Requirement already satisfied: click>=5.1 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.10->Flask-SQLAlchemy) (7.0)                                                                                   
Requirement already satisfied: Werkzeug>=0.15 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.10->Flask-SQLAlchemy) (0.16.0)                                                                            
Requirement already satisfied: MarkupSafe>=0.23 in /usr/lib/python2.7/dist-packages (from Jinja2>=2.10.1->Flask>=0.10->Flask-SQLAlchemy) (0.23)  

I have gone down about every website I can find on how to fix this, but I'm lost. This is for a Flask app I have worked on for a while on Replit.com and it worked fine until the transfer to PythonAnywhere. I have been trying to get this out for around two weeks now ^~^ but yet still no luck to my avail. I used a lot of this guide to help me with it, as I am also practicing my web deployment skills. (Don't need judgment on the fact I'm using flask -3-) But could anyone take thier time to help me with this? If you can, thanks a lot.

2 Answers 2

1

Hello @TutorialWarrior9776 my suggestion is:

Step 1: Install virtualenv,

pip install virtualenv

Step 2: Create env

virtualenv -p python3.8 NAME_ENV

Step 3: Activate env and Install requirements.txt (file generated local machine contains module flask_migrate)

source NAME_ENV/bin/active

pip install -r requirements.txt

Step 4: Set your env path in the section (web) of pythonanywhere, that's all;

https://help.pythonanywhere.com/pages/Virtualenvs/

(Section: Step 3: Configure your app to use this virtualenv)

Hope this helps ;)

Sign up to request clarification or add additional context in comments.

2 Comments

thats actually what the solution was! glad you could help, and i marked it as being correct ^-^
That's cool, I like to help, I've been there.
0

Check if your web app on PythonAnywhere is set up to be run by Python 2.7 -- I see you're using pip install outside of a virtual environment which by default will use pip for Python 2.7 as you can see in the output (btw. it won't work on PythonAnywhere, you need to provide --user option). If you want to install packages outside of virtual environment for different version of Python, use pipX.X install --user ... (where X.X should be replaced by required Python version). Also, remember to reload the web app every time the setup is changed. And if you're really stuck, maybe try contacting PythonAnywhere support ([email protected]) or use their forums?

3 Comments

Ok, I will try doing this. My only problem would be having to uninstall all these modules first, and in which doing that raises an error. Then after reinstalling them (if I can uninstall them) I would still have to figure out where in the directory to install them to. I also have contacted them, but still havnt found a working solution. Thx tho ^-^
Well, @caseneuve I did do as instructed. It halfway worked, so now i am getting a different error thrown at me, one of a familiar instance. Now its saying I am getting an import error of flask_login, which is funny because I just ran the pip install command as you said, but it said it was already installed. I'm not exactly sure what I should do about this. Any Ideas?
What was the exact command that you ran to do the pip install?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.