我正在尝试使用Google App Engine在个人项目中使用Datastore。但是,无论我怎么努力,我都无法导入数据存储模块。
我一直在使用在线控制台(为了避免首先在我的电脑上然后在GCloud上解决问题......)
所以,我正在使用
from google.cloud import datastore
不幸的是,那根本不起作用。我遇到的最后一个错误是
ImportError: No module named google.protobuf
但在我有Can't import Datastore.
我所做的是删除/ lib的完整性,并用pip重新安装每个依赖项。这是我的requirements.txt
:
# This requirements file lists all third-party dependencies for this project.
#
# Run 'pip install -r requirements.txt -t lib/' to install these dependencies
# in `lib/` subdirectory.
#
# Note: The `lib` directory is added to `sys.path` by `appengine_config.py`.
Flask==0.10
google.cloud==0.25.0
protobuf==3.3.0
(添加了最后一行以尝试解决我收到的最后一个错误)。在出现此错误之前,我得到了
此外,还有一个澄清问题:我看过(在寻找答案时)使用gcloud
的人和使用google.cloud
的人。有什么不同?我该怎么用?
此外,pip show google.cloud
没有显示任何内容。
我错过了什么?
谢谢
答案 0 :(得分:0)
好吧,如果有人想知道,我在这里解决了这个问题。解决这个问题的原因是将Flask版本更改为0.12(不知道为什么,但发生了什么)。
我删除def "Exception Testing 1"(){
given :
def fooObject = mock(Foo);
when:
doThrow(RuntimeException).when(fooObject).foo()
then:
thrown RuntimeException
}
def "Exception Testing 2"(){
given :
def fooObject = Mock(Foo);
when:
when(fooObject.foo()).thenThrow(RuntimeException)
then:
thrown RuntimeException
}
以确保我从头开始。然后,我使用了这个lib
文件:
requirements.txt
(Flask 0.12需要Flask==0.12
google-cloud==0.25.0
click==5.1
)。