You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决Notebook运行预测时的‘name 'aiplatform' is not defined’错误?

解决NameError: name 'aiplatform' is not defined错误的方法
  • 安装google-cloud-aiplatform库
    在Notebook的代码单元格中执行安装命令:

    !pip install google-cloud-aiplatform
    

    若需要指定版本,可添加版本号,例如:

    !pip install google-cloud-aiplatform==1.35.0
    
  • 在代码中导入aiplatform模块
    在调用aiplatform相关功能的代码前,添加导入语句:

    import aiplatform
    
  • 额外注意点

    • 若在Google Colab中使用,需先完成身份验证以获取资源访问权限,执行:
      from google.colab import auth
      auth.authenticate_user()
      
    • 检查导入语句拼写,aiplatform为全小写,避免大小写错误导致的导入失败。

内容的提问来源于stack exchange,提问作者Jeremiah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 11:45:36