簡體   English   中英

ImportError:沒有名為SQLAlchemy的模塊。 GAE和webapp2

[英]ImportError: No module named SQLAlchemy. GAE and webapp2

我正在嘗試在Google App Engine上將SQLAlchemy與webapp2一起使用。 我正在eclipse中進行開發,並且eclipse from sqlalchemy import create_engine識別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開發還比較陌生,所以也許我缺少明顯的東西。 任何幫助將不勝感激。 謝謝!

在本地計算機上,您已經安裝了sqlalchemy。 在appengine上,您沒有它,這就是導入失敗的原因。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM