I have a new compute instance that has Python3.8 and Python3.9 and in Azure Notebook some libraries not found.

Phelps, Ronald (Ron) (CIV) 40 Reputation points
2024-08-21T21:12:17.58+00:00

I created a new compute based on an earlier one from Dec 2023.

Dec 23 compute has Python3.8

New compute has Python3.8 and Python3.9.

Azure notebook uses Python 3.9.19

From command line "import sklearn" works for 3.8 and 3.9

Azure notebook can't import - No module named 'sklearn'

Kernel selected is "Python3.8 Pytorch and Tensorflow" in notebook

Don't have a fix for this. Suggestions?

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,957 questions
0 comments No comments
{count} votes

Accepted answer
  1. romungi-MSFT 46,751 Reputation points Microsoft Employee
    2024-08-22T06:44:22.0433333+00:00

    @Phelps, Ronald (Ron) (CIV) I think you need to install the same using pip magic command i.e using % inside a notebook. Here is a screen shot where the same works after installing using magic command.

    User's image

    Please check if this works for you. Thanks!!

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2024-08-21T21:12:17.5966667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    It seems like the issue is that the required libraries are not installed in the Azure Notebook environment. Instead of using !pip install... to install packages in Azure ML notebooks, you can use %pip line magic within a notebook or install from a terminal. Here are the steps to install the sklearn package from a terminal:

    1. Open a terminal in Azure ML notebooks and run the following commands:
    conda activate azureml_py38
    pip install --upgrade scikit-learn
    
    1. Close the terminal and restart the kernel.

    This should install the sklearn package and allow you to import it in your notebook.


    References:


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.