Process to change environment of an Azure ml pipeline "Execute Python Script"

96 Views Asked by At

I installed a Python library in a custom environment of an Azure ML pipeline to run an "Execute Python Script". But I'm unable to understand what process I need to follow to change the environment of that "Execute Python Script".

enter image description here

This one I want to change. In "Docker args" I specify a custom environment's name, but it does not work. I am not sure if it is the proper way.

enter image description hereenter image description here

"pipeEnvTe" my custom environment's name

1

There are 1 best solutions below

2
Rishabh Meshram On

Based on the documentation, the Execute Python Script component make use of default environment which is based on Anaconda distribution of Python. So, it seems there is no direct way to change the environment.

One possible solution is by installing required packages that aren't in the pre-installed list.

Below is sample code to add in your python script that will install the required package:

import importlib.util
package_name = 'scikit-misc'
spec = importlib.util.find_spec(package_name)
if spec is None:
    import os
    os.system(f"pip install scikit-misc")

With the above code snippet added to the python script I was able to include required package in the Execute Python Script component. enter image description here

This way you can include all the required packages with are not in Preinstalled Python packages List.