I'm following this guide and trying to develop a Flask app to run on the Google App Engine. I followed the guide to the letter but when I launch the dev app server from the Launcher and go to http://localhost:8080/, I get a HTTP 500 error.
I check the logs and it says No module named flask
. Then I check the interactive console in the admin console by running import flask
and I get the same error message. I can import flask in any other python file without error.
Is there a way to fix this?
Working a bit with GAE and Flask I have realized this:
Running directly with Python
To run the app with python directly (python app.py
) you need have the dependents packages installed in your environment using the command: pip install flask
Running with dev_appserver.py
To run the app with the dev_appserver.py provided by GAE SDK you need have all dependent packages inside your project, as: Flask, jinja2... Look in my another answer a example how to configure this packages : https://stackoverflow.com/a/14248647/1050818
Running Python, Virtualenv, Flask and GAE on Windows
Install Python
;C:\Python27;C:\Python27\Scripts
at the end of the value and saveInstall setuptools MS Windows installer (Necessary to install PIP on Windows)
Install PIP
python setup.py install
Install Virtualenv
pip install virtualenv
mkdir c:\virtualenvs
to create a folder to the Virtual Envscd c:\virtualenvs
to access that foldervirtualenv flaskdemo
to create a virtualenv for you projectc:\virtualenvs\flaskdemo\scripts\activate
Install Google App Engine SDK
Create the project
(Look a example of the code here: https://github.com/maxcnunes/flaskgaedemo )
Install Flask to run Locally
pip install flask
Install Flask to run on the GAE
Running the application with GAE SDK
Usually, templates come with a requirements.txt
. If not, add your dependencies there and then run pip install -t lib -r requirements.txt
to force the libraries to be saved in the lib
folder.
Make sure you've added lib
to appengine_config.py
with vendor.add('lib')
if it's not already there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With