Search code examples
pythongoogle-app-enginesqlalchemyimporterrorwebapp2

ImportError: No module named SQLAlchemy. GAE and webapp2


I am trying to use SQLAlchemy with webapp2 on google app engine. I am developing in eclipse and eclipse recognizes from sqlalchemy import create_engine as a valid import. However, when I run the GAE project and visit localhost:8080 I get the following error:

Traceback (most recent call last):

File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 239, in Handle

handler = _config_handle.add_wsgi_middleware(self._LoadHandler())

File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py",     line 298, in _LoadHandler

handler, path, err = LoadObject(self._handler)

File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 84, in LoadObject

obj = __import__(path[0])

File "C:\Users\Matthew\Development\Python\repos\trainingdb\app_engine_workspace\TrainingEngineProject\main.py", line 2, in <module>

import handlers

File "C:\Users\Matthew\Development\Python\repos\trainingdb\app_engine_workspace\TrainingEngineProject\handlers.py", line 2, in <module>

from sqlalchemy import create_engine

ImportError: No module named sqlalchemy

INFO     2014-06-21 10:30:05,214 module.py:639] default: "GET / HTTP/1.1" 500 -

Here are my project files:

app.yaml

application: tdg-manager
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /static
  static_dir: static
- url: /
  script: main.app

libraries:
- name: webapp2
  version: latest

main.py

import webapp2
import handlers

routes = [
    (r'/', handlers.MainHandler),
]
app = webapp2.WSGIApplication(routes=routes,
                              debug=True)

handlers.py

import webapp2
from sqlalchemy import create_engine

class MainHandler(webapp2.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'
        self.response.out.write("Hello world")

I am relatively new to GAE and web development in general, so perhaps I am missing something obvious. Any help would be greatly appreciated. Thanks!


Solution

  • On you local machine you have sqlalchemy installed. On appengine you don't have it thats why your import is failing.