据我所知,我已经设置了我的烧瓶应用程序。包含所有依赖项的lib在我的root下,并包含Requirements.txt中包含的内容。我的appengine_config.py
包含以下
print 'running app config yaya!'
from google.appengine.ext import vendor
import os
import sys
print os.path
print os.path.realpath
print os.path.realpath(__file__)
print os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib')
sys.path.insert(0,'./lib')
vendor.add('lib')
print 'I am the line after adding lib, it should have worked'
根据所有这些打印陈述,没有任何错误,但我正在
No module named flask_sqlalchemy
在部署并看到500之后。为了安装这些吸盘,我缺少什么?
EDIT --------------- 谢谢,在这里 -
running app config yaya!
18:36:29.499
['./lib', '/base/data/home/apps/s~nimble-poet-150223/20161221t183424.397920801519685819', '/base/data/home/runtimes/python27/python27_dist/lib/python27.zip', '/base/data/home/runtimes/python27/python27_dist/lib/python2.7', '/base/data/home/runtimes/python27/python27_dist/lib/python2.7/plat-linux2', '/base/data/home/runtimes/python27/python27_dist/lib/python2.7/lib-tk', '/base/data/home/runtimes/python27/python27_dist/lib/python2.7/lib-old', '/base/data/home/runtimes/python27/python27_dist/lib/python2.7/lib-dynload', '/base/data/home/runtimes/python27/python27_dist/lib/python2.7/site-packages', '/base/data/home/runtimes/python27/python27_lib/versions/1', '/base/data/home/runtimes/python27/python27_lib/versions/third_party/jinja2-2.6', '/base/data/home/runtimes/python27/python27_lib/versions/third_party/markupsafe-0.15', '/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0', '/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.3', '/base/data/home/runtimes/python27/python27_lib/versions/third_party/webob-1.1.1', '/base/data/home/runtimes/python27/python27_lib/versions/third_party/yaml-3.10']
18:36:29.499
['PYTHON_VERSION', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'add', 'os', 'site', 'sys']
18:36:29.503
I am the line after adding lib, it should have worked
18:36:29.948
(/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~nimble-poet-150223/20161221t183424.397920801519685819/main.py", line 6, in <module>
from nimble import *
File "/base/data/home/apps/s~nimble-poet-150223/20161221t183424.397920801519685819/nimble/__init__.py", line 10, in <module>
from flask_sqlalchemy import SQLAlchemy, SignallingSession
ImportError: No module named flask_sqlalchemy
18:36:30.191
This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.
不确定它是否相关,但我也得到https://code.google.com/p/google-cloud-sdk/issues/detail?id=729 但那个修复没有帮助
---更多编辑
我将所有内容从/ site_pakcages一个dir移到了/ lib并且我更近了,我的一些页面甚至正在工作!但现在我得到了
ImportError: No module named _sqlite3
但代码为
except ImportError as e:
try:
from sqlite3 import dbapi2 as sqlite # try 2.5+ stdlib name.
except ImportError as ee:
raise ee
return sqlite
为什么导入尝试会有下划线?帮助
答案 0 :(得分:0)
tldr:使用appengine_config.py并将你的virtualenv复制到一个名为lib的文件夹,然后确保你通过dev_appserver.py
运行应用程序(以下是ubuntu中的bash)经过长时间的战斗后,我发现虚拟环境和gcloud不会很好玩 -
我复制了虚拟环境
中的所有内容... /。virtualenvs /敏捷/ local / lib目录/ python2.7 /站点包
到
[PROJECTDIR] / lib中
并且我的appengine_config.py最终在本地工作,就像它在云中一样,但我绝对必须运行
dev_appserver.py [my proj dir here]
或google.appengine模块不会加载。不知道我应该使用dev服务器。我感到非常愚蠢。
供参考,下面是appengine_config.py
"""`appengine_config` gets loaded when starting a new application instance."""
print 'running app config yaya!'
from google.appengine.ext import vendor
vendor.add('lib')
print 'I am the line after adding lib, it should have worked'
import os
print os.getcwd()