将Google Cloud vision和pm2与python3脚本一起使用时出错

2024-06-30 15:11:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在取消绑定的服务器上运行脚本。该脚本所需的库之一是Google Cloud Vision。如果我使用python3命令,它可以在本地和服务器上工作-它只在使用pm2运行时抛出此错误

在运行pm2命令之前,我输入以下内容:export GOOGLE_APPLICATION_CREDENTIALS=ocr_keys.json

在这个命令之后,我键入:pm2 start controller.py --interpreter python3

然后,当我键入pm2 log时,我得到以下结果:

0|controll |   File "/root/planned2/bio.py", line 10, in <module>
0|controll |     from timeline import image_ocr, safe_status
0|controll |   File "/root/planned2/timeline.py", line 16, in <module>
0|controll |     OCR_CLIENT = vision.ImageAnnotatorClient()
0|controll |   File "/usr/local/lib/python3.6/dist-packages/google/cloud/vision_v1/gapic/image_annotator_client.py", line 165, in __init__
0|controll |     address=api_endpoint, channel=channel, credentials=credentials
0|controll |   File "/usr/local/lib/python3.6/dist-packages/google/cloud/vision_v1/gapic/transports/image_annotator_grpc_transport.py", line 70, in __init__
0|controll |     "grpc.max_receive_message_length": -1,
0|controll |   File "/usr/local/lib/python3.6/dist-packages/google/cloud/vision_v1/gapic/transports/image_annotator_grpc_transport.py", line 109, in create_channel
0|controll |     address, credentials=credentials, scopes=cls._OAUTH_SCOPES, **kwargs
0|controll |   File "/usr/local/lib/python3.6/dist-packages/google/api_core/grpc_helpers.py", line 177, in create_channel
0|controll |     credentials, _ = google.auth.default(scopes=scopes)
0|controll |   File "/usr/local/lib/python3.6/dist-packages/google/auth/_default.py", line 321, in default
0|controll |     raise exceptions.DefaultCredentialsError(_HELP_MESSAGE)
0|controll | google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started

感谢您的帮助

谢谢


Tags: inpyimagelibpackagesusrlocaldist