我正在尝试在Google App引擎上使用SQLAlchemy和webapp2。我在eclipse中开发,eclipse将from sqlalchemy import create_engine
识别为有效导入。但是,当我运行GAE项目并访问localhost:8080时,我收到以下错误:
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 -
以下是我的项目文件:
的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")
我对GAE和Web开发相对较新,所以也许我错过了一些明显的东西。任何帮助将不胜感激。谢谢!
答案 0 :(得分:0)
在本地计算机上安装了sqlalchemy。在appengine你不知道你输入失败的原因。