ImportError: No module named 'sklearn.linear_model._logistic': failing to import a locally train and serialized model

David Eeckhout 21 Reputation points
2021-03-31T23:49:06.277+00:00

I have tried importing a simple logistic regression model into Azure ML to use in a Execute Python Script-module It's attached the correct way, but I keep getting the same error. From what I understand this has to do with the version of scikit-learn and scipy, but I created venv for almost every possible version of Python.

Error 0085: The following error occurred during script evaluation, please view the output log for more information:
---------- Start of error message from Python interpreter ----------
Caught exception while executing function: Traceback (most recent call last):
File "C:\server\invokepy.py", line 199, in batch
odfs = mod.azureml_main(*idfs)
File "C:\temp\8c190f6b5c65446f8824ed5a578a75d5.py", line 22, in azureml_main
model = pickle.load( open( "./Script Bundle/logreg_model_36.pkl", "rb" ) )
ImportError: No module named 'sklearn.linear_model._logistic'
Process returned with non-zero exit code 1

Can someone please explain which version of scikit-learn I need to execute in Azure ML studio (classic) with the environment set to 'Anconda 4.0/Python3.5'?

Kind regards

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

Accepted answer
  1. romungi-MSFT 48,906 Reputation points Microsoft Employee Moderator
    2021-04-01T07:15:51.653+00:00

    @David Eeckhout The packages installed in the designer version of the studio are listed here which uses the following versions:

    scikit-learn==0.22.2  
    scipy==1.4.1  
    

    The classic version of the studio is still available but it is preferable to use the designer studio which has better support for some of the pre-installed packages.
    If you prefer to use classic version then if the package is not available you can try installing it in the execute python script. For example,

    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")  
    

    Hope this helps.


1 additional answer

Sort by: Most helpful
  1. Prasad Vinay Mukkawar 5 Reputation points
    2023-03-10T09:19:26.35+00:00

    try changing the kernel for me the "azureml 3.8" worked.

    no module not found error.

    1 person found this answer helpful.
    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.