3

I'm following this tutorial and I'm trying to develop a basic Flask app to run on the Google App Engine. I am using Windows and have followed the guide exactly at every step.

  1. I have set up my Virtual Environment and tested if flask was in it using the import sys in the virtual environment interpreter and it is there. simpleJson, Werkzeug, and Jinja2 are also there. I installed them using pip install in the virtual environment.

  2. After checking the logs I only get a <type 'exceptions.ImportError'> saying:

<type 'exceptions.ImportError'>: No module named flask 
      args = ('No module named flask',) 
      message = 'No module named flask'
  1. This is my folder structure:
gae/
   /app/
      __init__.py
      models.py
      settings.py
      views.py
   /venv/
         /Include
         /Lib
         /Scripts
   /flask/
   /simplejson/
   /werkzeug/
   /jinja2/

   app.yaml
   main.py

I have read different questions here and googled similar issues, but after trying several possible solutions, I am still not able to fix it. At this point I don't know what I am missing, I am new to flask and GAE. Any suggestion on what I am doing wrong? Thanks in advance.

This is my init.py:

from flask import Flask
import settings

app = Flask('app')
app.config.from_object('app.settings')

import views

This is my app.yaml:

application: app
version: 1
runtime: python
api_version: 1

handlers:
- url: .*
  script: main.py

This is how my requirements.txt looks:

Flask==0.9  
Jinja2==2.6 
Werkzeug==0.8.3 
simplejson==3.0.7

This is my main.py:

from google.appengine.ext.webapp.util
import run_wsgi_app from app import app

run_wsgi_app(app)
lv10
  • 1,469
  • 7
  • 25
  • 46
  • See [this example](http://mostovenko.blogspot.ro/2012/08/launching-flask-on-google-app-engine-gae.html). Maybe it helps – doru Jan 11 '13 at 16:04
  • 1
    could you dump your requiremets of your virualenv. pip freeze > requirements.txt – jassinm Jan 11 '13 at 20:53

3 Answers3

2

Look my answer to a similar question, explaining step by step how to run Python, Flask, Virtualenv and Google App Engine on Windows and verify if you are doing on same way: Can't import Flask while using Google App Engine

Community
  • 1
  • 1
maxcnunes
  • 2,927
  • 1
  • 20
  • 26
  • thanks for your suggestion. I following your post update, however, still I get the same error. I did a `pip freeze > requirements.txt` and this are these are the listed libraries: Flask==0.9, Jinja2==2.6, Werkzeug==0.8.3, simplejson==3.0.7 – lv10 Jan 15 '13 at 18:24
  • I have updated my original post to reflect the changes I made based on your suggestion. Please let me know if there is any other info I should provide you with. Thanks! – lv10 Jan 15 '13 at 19:30
  • Could you add the main.py file? – maxcnunes Jan 18 '13 at 12:23
  • Thanks Max, I have update the original post with the main.py. It is at the end of the post. Thanks in advance. – lv10 Jan 18 '13 at 16:26
  • Please, try move the app.yaml and main.py to inside the gae folder. – maxcnunes Jan 19 '13 at 19:45
  • Sorry, it looks like app.yaml and main.py are not inside the gae folder from my post. I have updated the post, and in my computer they are in there. So both app.yaml and main.py are inside the gae folder. I have some additional things but still it doesn't start, I keep on getting the same error. – lv10 Jan 19 '13 at 21:59
  • I have tried to do a simple basic `hello world` app and I keep on getting the same problem. – lv10 Jan 19 '13 at 23:05
  • @lv10, This is really strange, I created the same structure here and this is working well. Are you running the application from Google App Engine Launcher? Maybe because of you are using the venv directory is causing a problem to run the application. If possible contact me on skype and I can help more. – maxcnunes Jan 20 '13 at 01:19
  • Yes I am using Google App Launcher. I just added you on Skype. Thank you very much. – lv10 Jan 20 '13 at 01:40
  • thanks. After removing the venv and testing for basic `hello world` it works now. Thanks Max! – lv10 Jan 20 '13 at 03:20
0

visit link given below; its a boilerplate project template for running a Flask-based application on Google App Engine (Python)
https://github.com/kamalgill/flask-appengine-template

namit
  • 6,780
  • 4
  • 35
  • 41
  • Does the file structure has to be: `root/src/`? or could it be just `root/'contents of the src folder from the project template'`? – lv10 Jan 17 '13 at 14:54
-1

Try sticking a blank init.py file in the root gae directory, then make your import:

from gae.flask import Flask
dlorenc
  • 531
  • 3
  • 8