简体   繁体   中英

Add sqlalchemy library to google app engine in pycharm

I have following question to sqlalchemy in gae. I'm using the integrated google app engine sdk from Pycharm . Everything works fine, except the integration of sqlalchemy . The database itself works fine if I debug it with the Python interpreter. But when I'm trying to run it together with the google app engine I'm getting troubles with the import of the sqlalchemy library.

I already tried to solve it with virtualenv, but it didn't work either.

Here is my output log:

Connected to pydev debugger (build 131.618)

WARNING 2014-02-17 10:58:22,887 api_server.py:331] Could not initialize images API; you are likely missing the Python "PIL" module.

WARNING 2014-02-17 10:58:22,895 simple_search_stub.py:1018] Could not read search indexes from c:\\users\\user\\appdata\\local\\temp\\appengine.test\\search_indexes

INFO 2014-02-17 10:58:22,947 api_server.py:138] Starting API server at: localhost:60878

INFO 2014-02-17 10:58:22,994 dispatcher.py:171] Starting module "default" running at: localhost:8080

INFO 2014-02-17 10:58:23,032 admin_server.py:117] Starting admin server at: localhost:8000

pydev debugger: process 4452 is connecting

pydev debugger: process 4196 is connecting

ERROR 2014-02-17 09:58:35,742 wsgi.py:262] 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\\user\\PycharmProjects\\test\\main.py", line 16, in from bin.database.DBList import DBList

File "C:\\Users\\user\\PycharmProjects\\test\\bin\\database\\DBList.py", line 17, in from sqlalchemy import Column, Integer, String

ImportError: No module named sqlalchemy

INFO 2014-02-17 10:58:36,410 module.py:617] default: "GET / HTTP/1.1" 500 -

So how is it possible to add a third party library in gae ?

This is to be expected because GAE has no idea what things your virtualenv is using. To mitigate this problem of using a third party library, all you need to do is download the source code of the library and all its dependents, and put it into a folder underneath your root project directory.

Add the folder to your PYTHONPATH , you can do this via:

import sys; sys.path.append('<your relative path to directory here>')

And then you are all set. By convention this directory that you put all your third party libraries under, is called lib .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM