GAE - 将 VM 设置为 true 和共享库

GAE - Setting VM to true and shared libraries altogether

当我的 app.yaml

上的 VM true 标志设置为 true 时,我一直在尝试使用 MySql

但抛出此错误:appcfg.py:错误:解析 src/app.yaml 时出错:托管 VM 已弃用 "libraries:" 指令。请从您的 app.yaml 中删除此部分,使用 pip (https://pip.pypa.io/) 安装 您的依赖项,并将它们保存到 requirements.txt。欲了解更多信息,请访问 http://cloud.google.com/python.

我没有找到任何关于此错误的具体信息,我应该把它放在哪里 "requirement.txt",有人遇到过这个问题吗?

谢谢!

如果您正在使用灵活的环境(以前称为托管虚拟机),那么您不能在 app.yaml 中使用 "libraries" 指令来激活第三方库。相反,你应该使用 pip 来安装你的依赖项。来自 oficial docs;

Requirements.txt and the Python package manager pip are used to declare and install application dependencies.

作者写的时候文档也很明确;

Requirements.txt defines the libraries that will be installed both locally and when deploying to App Engine.

你应该把requirement.txt文件放在根目录下。 Here 你可以看到导入 flask 库的例子。

在您的开发环境中,您可以运行以下命令来安装您声明的库。

pip install -r requirements.txt

Pip 是在 python 环境中安装库的默认方式。 Here 你可以找到一个非常好的文档。

更新:

您应该使用以下命令进行部署:

gcloud proview app deploy 

查看 here 了解更多详情。

此外,here您的用例有一个官方示例。我可以看出一点不同,作者使用的是 PyMySQL==0.7.3 而不是 MySQL-python.