I'm trying to run a Python script in a DevOps pipeline upon check in. A basic 'hellow world' script works, but when I import azureml.core, it errors out with ModuleNotFoundError: No module named 'azureml'.
That makes sense, since I don't know how it was going to find azureml.core. My question is: how do I get the Python script to find the module? Do I need to check it in as part of my code base in DevOps? Or is there some way to reference it via a hyperlink?
Here is my YML file:
trigger:
- master
pool:
vmImage: ubuntu-latest
steps:
- task: PythonScript@0
inputs:
scriptSource: 'filepath'
scriptPath: test.py
And here is my python script:
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))
You have to install the lost package into your python, the default python does not have that. Please use the below 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