python - DevOps 管道在导入 azureml.core 时运行 python 脚本错误
问题描述
我正在尝试在签入时在 DevOps 管道中运行 Python 脚本。一个基本的“hellow world”脚本可以工作,但是当我导入 azureml.core 时,它会出现 ModuleNotFoundError:没有名为“azureml”的模块。
这是有道理的,因为我不知道它将如何找到 azureml.core。我的问题是:如何让 Python 脚本找到模块?我是否需要将其作为 DevOps 代码库的一部分签入?或者有什么方法可以通过超链接引用它?
这是我的 YML 文件:
trigger:
- master
pool:
vmImage: ubuntu-latest
steps:
- task: PythonScript@0
inputs:
scriptSource: 'filepath'
scriptPath: test.py
这是我的python脚本:
print('hello world')
import azureml.core
from azureml.core import Workspace
# Load the workspace from the saved config file
ws = Workspace.from_config()
print('Ready to use Azure ML {} to work with {}'.format(azureml.core.VERSION, ws.name))
解决方案
你必须将丢失的包安装到你的 python 中,默认的 python 没有。请使用以下 yml:
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: UsePythonVersion@0
displayName: 'Use Python 3.8'
inputs:
versionSpec: 3.8
- script: python3 -m pip install --upgrade pip
displayName: 'upgrade pip'
- script: python3 -m pip install azureml.core
displayName: 'Install azureml.core'
- task: PythonScript@0
inputs:
scriptSource: 'filepath'
scriptPath: test.py
推荐阅读
- react-native - ./gradlew assembleRelease 时 React-native 包发布错误
- javascript - 在 Reporter Cypress 中输出日志
- django - 您能否制作一个基于随机变量将用户重定向到另一个应用程序的视图?
- python - 在python中需要一个更好的输入表单
- python - 如何使用 ImageDataGenerator 洗牌?
- c# - c#基类方法返回派生类
- javascript - HotJar 在用户通过 JavaScript 被定向到网站的另一个部分后突然结束
- typescript - TS 4.1 从 lib.dom.d.ts 中删除了 Position 接口。我应该如何更改使用位置的代码?
- java - java继承对象列表
- c++ - 使用归并排序对数组进行排序