依赖项未从 google 应用引擎中的 lib 目录安装
Dependencies not installing from lib directory in google app engine
据我所知,我已经正确设置了我的 Flask 应用程序。包含所有依赖项的 lib 位于我的根目录,并包含 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 后。我缺少什么来安装这些吸盘?
编辑----------------
谢谢,这里 --
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 向上移动到 /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
为什么这里的导入尝试会有下划线?有帮助吗?
tldr:使用 appengine_config.py 并将您的 virtualenv 复制到名为 lib 的文件夹,然后确保您正在通过 dev_appserver.py
运行安装应用程序
(下面是通过bash in ubuntu)所以经过长时间的战斗,我发现虚拟环境和gcloud 玩得不好-
我从我的虚拟环境目录中复制了所有内容
.../.virtualenvs/nimble/local/lib/python2.7/站点包
进入
[项目目录]/lib
和我的 appengine_config.py 终于像在云中一样在本地工作了,但我绝对必须 运行
dev_appserver.py [my proj dir here]
或 google.appengine 模块无法加载。不知道我应该使用开发服务器。我觉得很傻。
供参考,这里是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()
据我所知,我已经正确设置了我的 Flask 应用程序。包含所有依赖项的 lib 位于我的根目录,并包含 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 后。我缺少什么来安装这些吸盘?
编辑---------------- 谢谢,这里 --
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 向上移动到 /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
为什么这里的导入尝试会有下划线?有帮助吗?
tldr:使用 appengine_config.py 并将您的 virtualenv 复制到名为 lib 的文件夹,然后确保您正在通过 dev_appserver.py
运行安装应用程序(下面是通过bash in ubuntu)所以经过长时间的战斗,我发现虚拟环境和gcloud 玩得不好-
我从我的虚拟环境目录中复制了所有内容
.../.virtualenvs/nimble/local/lib/python2.7/站点包
进入
[项目目录]/lib
和我的 appengine_config.py 终于像在云中一样在本地工作了,但我绝对必须 运行
dev_appserver.py [my proj dir here]
或 google.appengine 模块无法加载。不知道我应该使用开发服务器。我觉得很傻。
供参考,这里是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()