简体   繁体   English

是否有独立 Python3 的谷歌云翻译示例?

[英]Is there an example of Google cloud translate for standalone Python3?

I am trying to figure out how to use google cloud translate in my own Python3 environment.我想弄清楚如何在我自己的 Python3 环境中使用谷歌云翻译。 I have completed the codelabs tutorial that shows me how to do it in the cloud shell, but I want to run it from my own environment.我已经完成了codelabs 教程,该教程向我展示了如何在云 shell 中进行操作,但我想从自己的环境中运行它。 I can install the google-cloud-translate library of course but I have no idea how to set up authentication, which in the tutorial uses a bunch of cloud shell commands that (AFAIK) I can't run from my Linux shell.我当然可以安装 google-cloud-translate 库,但我不知道如何设置身份验证,在本教程中使用了一堆云 shell 命令(AFAIK)我无法从我的 Linux Z2591C98B1ZE9124 运行

I did get a copy of the key.json file created in that process, in hopes there is a way to use that for my standalone system.我确实得到了在该过程中创建的 key.json 文件的副本,希望有一种方法可以将其用于我的独立系统。 But after quite a bit of searching I've not found any instructions for setting up authentication using that file or otherwise.但是经过相当多的搜索后,我没有找到任何使用该文件或其他方式设置身份验证的说明。 There is a guide for setting up a Python dev environment, but it says nothing about authentication.有设置 Python 开发环境的指南,但它没有说明身份验证。

Can anyone point me to a tutorial or worked example?谁能指出我的教程或工作示例?

You can first install Cloud SDK , like someone on the comments said.您可以先安装Cloud SDK ,就像评论中有人说的那样。

After that, to authenticate I would set up the GOOGLE_APPLICATION_CREDENTIALS environment variable with the path to your service account key之后,为了进行身份验证,我将使用您的服务帐户密钥的路径设置 GOOGLE_APPLICATION_CREDENTIALS 环境变量

export GOOGLE_APPLICATION_CREDENTIALS="/path/to/my/service-account-key.json"

You can add it to your .bashrc if you don't want to run it each time you log in如果您不想在每次登录时都运行它,可以将其添加到您的.bashrc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JSONDecodeError 使用 Google Translate API 和 Python3 - JSONDecodeError using Google Translate API with Python3 包括 Google Cloud Datastore Python3 AttributeError - Google Cloud Datastore Python3 AttributeError on include Google Cloud App Engine的最佳做法:Python2或Python3? - Best practices with google cloud app engine: Python2 or Python3? 通过HTTP代理的Python3 BigQuery或Google Cloud Python - Python3 BigQuery or Google Cloud Python through HTTP Proxy Python3 中的 Cloud Function - 从 Google Cloud Bucket 复制到另一个 Google Cloud Bucket - Cloud Function in Python3 - copy from Google Cloud Bucket to another Google Cloud Bucket 如何在谷歌云数据中激活python3 - how to activate python3 in Google-cloud-data 如何在Google Cloud Platform中为Node应用程序安装Python3 - How to install Python3 in Google Cloud Platform for a Node app 在Google云集群Python3的Jupyter Notebook中设置可执行文件PATH - set executable PATH in Jupyter Notebook on google cloud cluster Python3 Google Cloud Functions Python3:使用端点包装 HTTP 触发器函数 - Google Cloud Functions Python3: Wrapping HTTP trigger functions with endpoints python3上的打印语句不再登录谷歌云平台 - Print statements on python3 no longer logging on Google Cloud Platform
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM