但是当我运行代码时,出现此错误:
client = google.cloud.logging.Client() AttributeError: module 'google.cloud' has no attribute 'logging'
我不明白为什么这样,因为使用pyCharm
它向我展示了方法
我的代码:
import unittest
import os
from dotenv import load_dotenv
load_dotenv(verbose=True)
from google.oauth2 import service_account
import google.cloud.logging
import unit_test
script_dir = os.path.dirname(__file__)
file_path = os.path.join(script_dir, os.getenv('FIREBASE_ADMIN_CREDENTIAL_PATH'))
credentials = service_account.Credentials.from_service_account_file(
file_path)
client = google.cloud.logging.Client()
答案 0 :(得分:1)
您需要在本地环境中安装google-cloud-logging
软件包,或将其添加到requirements.txt
中,具体取决于您尝试在何处运行代码:
在本地安装:
pip install --upgrade google-cloud-logging
或添加到requirements.txt
google-cloud-logging