python - google.api_core.exceptions: 403 调用者没有权限
问题描述
我正在使用google cloud automl tables api,当我对该方法执行url请求时,它给了我这个错误:
google.api_core.exceptions.PermissionDenied: 403 调用者没有权限
参数是正确的,为什么它告诉我那个错误!
@app.route('/model_train',methods=['GET','POST'])
def model_train():
project_id = 'myproject'
compute_region = 'us-central1'
model_id = 'TBL7912987273010'
file_path = 'E:/downloads/Dataset-entrainement-demain_ai_demonstrateur_attrition_Oct19_Copie.csv'
score_threshold = '0.5'
automl_client = automl.AutoMlClient()
model_full_id = automl_client.model_path(
project_id, compute_region, model_id
)
prediction_client = automl.PredictionServiceClient()
params = {}
if score_threshold:
params = {"score_threshold": score_threshold}
with open(file_path, "rt") as csv_file:
content = csv.reader(csv_file)
for row in content:
values = []
for column in row:
values.append({'number_value': float(column)})
payload = {
'row': {'values': values}
}
response = prediction_client.predict(model_full_id, payload)
print("Prediction results:")
for result in response.payload:
print("Predicted class name: {}".format(result.display_name))
print("Predicted class score: {}".format(result.classification.score))
谁能帮帮我!
解决方案
推荐阅读
- python - Tensorflow模型无法完全删除仍占用CPU内存
- sql - 根据同一行中的行值逐行更新列值
- arrays - cannot use make([]Entry, 0, 100) (type []Entry) as type Map in assignment
- java - 休眠中的 OneToMany 映射。值即将为空
- reactjs - 提交表单后不获取值
- angular - Angular - 如何在 VS Code 的 html 文件中更改变量的颜色?
- flutter - 如何获取用户当前的订阅状态,验证订阅是否仍然有效?
- javascript - 我想捆绑一个没有起点的文件夹 - Webpack
- python - pytz 包:即使通常使用 python3,也只能与 python2 一起运行(在 pip install pytz 之后)
- flutter - 当它的孩子被定义为类成员时,GridView 不会重绘