【发布时间】:2020-02-24 12:53:06
【问题描述】:
我正在我的 Mac 上使用 VSCode 在我的 Django 项目上测试 Google Cloud Pub/Sub,但在调试测试期间设置 GCP 环境变量时遇到了一些问题,特别是 GOOGLE_APPLICATION_CREDENTIALS 环境变量。
我可以设置GOOGLE_APPLICATION_CREDENTIALS 以在shell 中使用export GOOGLE_APPLICATION_CREDENTIALS="path/to/json_credential_file.json" 在本地运行服务器和/或测试,但是由于VSCode 调试器在单独的shell 中运行,因此在调试测试时未设置env 变量。我尝试将相同的值添加到launch.json 中的env 键:
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "path/to/json_credential_file.json"
}
但它仍然抱怨没有设置 GOOGLE_APPLICATION_CREDENTIALS:
oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
有什么想法吗?
【问题讨论】:
标签: django visual-studio-code google-cloud-platform environment-variables vscode-debugger