lv10
lv10

Reputation: 1519

ImportError: No module named flask on google app engine

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)

Upvotes: 3

Views: 13600

Answers (3)

maxcnunes
maxcnunes

Reputation: 3027

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

Upvotes: 2

dlorenc
dlorenc

Reputation: 531

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

from gae.flask import Flask

Upvotes: -1

namit
namit

Reputation: 6957

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

Upvotes: 0

Related Questions