How to import azure.ai.ml in to local jupyter notebook running python?

Matt Chmielewski 0 Reputation points
2025-02-05T22:13:35.5733333+00:00

The 'Explore the Python SDK' module instructs users to initiate a connection the Azure ML client using this command from azure.ai.ml import MLClient. When I attempt to run this from a local jupyter notebook using Python 3.9.2 I get a ModuleNotFoundError: No module named 'azure' .

Is it possible to run these modules outside of the Azure Portal/ML environment?
If so, how do I run an import of the azure.ai.ml module whose name contains '.' and whose name is azure-ai-ml according to pip show azure-ai-ml?

Azure Training
Azure Training
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Training: Instruction to develop new skills.
2,023 questions
{count} votes

1 answer

Sort by: Most helpful
  1. VarunTha 12,345 Reputation points Microsoft Vendor
    2025-02-07T10:19:56.12+00:00

    Hi Matt Chmielewski,

    Thank you for reaching out to us on Microsoft Q&A forum.

    Yes, absolutely. You can run them outside of the Azure Portal/ML environment, including your local Jupyter Notebook. The ModuleNotFoundError you’re experiencing usually means that the Python package you need in your environment is not installed.

    The package you will need is called azure-ai-ml, which is part of the Azure Machine Learning SDK. To install it using pip, follow the steps below:

    1.Open terminal or command prompt.
    2.Run following command to install the package:

    pip install azure-ai-ml
    

    3.Once the installation is complete, restart your Jupyter Notebook kernel to ensure the changes take effect.

    After that, you should be able to import MLClient without any issues:

    from azure.ai.ml import MLClient
    

    If you’re still encountering issues, double-check that you’re using the correct Python environment in your Jupyter Notebook. You can verify this by running:

    import sys
    print(sys.executable)
    

    This will display the Python interpreter being used. Ensure it matches the environment where you installed azure-ai-ml.

    I hope this helps!

    If you have found the answer provided to be helpful, please click on the "Upvote and Accept Answer" button so that it is useful for other members in the Microsoft Q&A community.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.