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

将Google Cloud vision和pm2与python3脚本一起使用时出错,python,pm2,google-cloud-vision,Python,Pm2,Google Cloud Vision,我正在尝试在取消绑定的服务器上运行脚本。该脚本所需的库之一是Google Cloud Vision。如果我使用python3命令,它可以在本地和服务器上工作-它只在使用pm2运行时抛出此错误 在运行pm2命令之前,我输入以下内容:export GOOGLE\u APPLICATION\u CREDENTIALS=ocr\u keys.json 在这个命令之后,我键入:pm2 start controller.py——解释器python3 然后键入pm2 log时,我得到以下信息: 0|contr

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

在运行pm2命令之前,我输入以下内容:
export GOOGLE\u APPLICATION\u CREDENTIALS=ocr\u keys.json

在这个命令之后,我键入:
pm2 start controller.py——解释器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
0 | controll | File”/root/planned2/bio.py,第10行,在
0 |控制|从时间轴导入图像_ocr,安全|状态
0 | controll | File“/root/planned2/timeline.py”,第16行,在
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”,第165行,在u init中__
0 | controll | address=api|U端点,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”,第70行,初始__
0 |控制|“grpc.max|u receive|u message|u length”:-1,
0 | controll | File“/usr/local/lib/python3.6/dist packages/google/cloud/vision_v1/gapic/transports/image_annotator_grpc_transport.py”,第109行,在创建频道中
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”,第177行,创建频道
0 | controll | credentials,|=google.auth.default(scopes=scopes)
0 | controll | File“/usr/local/lib/python3.6/dist packages/google/auth/_default.py”,默认为第321行
0 |控制|引发异常。DefaultCredentialsError(_HELP_消息)
0 | controll | google.auth.exceptions.DefaultCredentialsError:无法自动确定凭据。请设置GOOGLE_应用程序_凭据或显式创建凭据并重新运行应用程序。有关更多信息,请参阅https://cloud.google.com/docs/authentication/getting-started
感谢您的帮助


谢谢

显式创建凭据选项怎么样?您已经解决了吗?遇到同样的问题显式创建凭据选项如何?您解决了吗?被困在同一个问题上