MachineLearningNotebooks: cannot import 'AutoMLConfig from azureml.train.automl

I tried to create a fresh environment using the three methods below. No matter what I can’t import from azureml.train.automl. Help!

  1. using automl/automl_env.yml from this repo: conda create env -n AML_BTB -f automl_env.yml
  2. The instructions given here.
  3. The instructions listed here: pip install --upgrade azureml-sdk[notebooks,automl]
  4. The instructions listed here
>>> from azureml.train.automl import AutoMLConfig
3.6.7 |Anaconda, Inc.| (default, Oct 28 2018, 19:44:12) [MSC v.1915 64 bit (AMD64)]
C:\Users\swanderz\Documents\attrition\aml_config\config.json
Found the config file in: C:\Users\swanderz\Documents\attrition\aml_config\config.json
avadevitsmlsvc  westus2 RG-ITSMLTeam-Dev        westus2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\swanderz\AppData\Local\Continuum\anaconda3\envs\AML_BTB\lib\site-packages\azureml\train\automl\__init__.py", line 12, in <module>
    from automl.client.core.common.utilities import extract_user_data, get_sdk_dependencies
  File "C:\Users\swanderz\Documents\attrition\automl.py", line 40, in <module>
    from azureml.train.automl import AutoMLConfig
ImportError: cannot import name 'AutoMLConfig'

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 25 (3 by maintainers)

Most upvoted comments

Thanks @swanderz! Your days of frustration that led you to your solution enabled me to solve the same problem in minutes.

I’m sorry this is so difficult, I can definitely empathize. I’m 85% sure that the issue has to do with your jupyter notebook is not using your conda environment.

Fix

Open the anaconda prompt and try this sequence of commands.

(base) C:\Users\anders.swanson>conda activate ret
(ret) C:\Users\anders.swanson>python
Python 3.6.2 |Anaconda, Inc.| (default, Sep 30 2017, 11:52:29) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from azureml.core import VERSION
>>> print("Azure ML SDK Version: ", VERSION)
Azure ML SDK Version:  1.3.0
>>> from azureml.train.automl import AutoMLConfig
>>>

If the above works, I recommend that you read this article about setting up an env on you local computer. Specifically the part about registering a new kernel w/ the ipykernel package.

Root Cause

Look at the path of your stacktrace. ~\AppData\Roaming\Python\Python36\site-packages\azureml\train\automl_init_.py The stacktrace should say something like

~\AppData\Local\Continuum\anaconda3\envs\{YOUR_ENV_NAME}\lib\site-packages\azureml\train\automl\__init__.py"

My guess is that you installed the Azure ML SDK into your system (i.e. non-anaconda) Python a long time ago. So all your conda work is valid, but jupyter is using a kernel pointing to the wrong place.

@swanderz here is the output

azureml-automl-core 1.2.0 azureml-automl-runtime 1.2.0 azureml-contrib-notebook 1.2.0 azureml-contrib-pipeline-steps 1.2.0 azureml-contrib-server 1.2.0 azureml-contrib-services 1.2.0 azureml-core 1.2.0.post2 azureml-dataprep 1.3.6 azureml-dataprep-native 14.1.0 azureml-defaults 1.2.0 azureml-explain-model 1.2.0 azureml-interpret 1.2.0 azureml-model-management-sdk 1.0.1b6.post1 azureml-pipeline 1.2.0 azureml-pipeline-core 1.2.0 azureml-pipeline-steps 1.2.0 azureml-sdk 1.2.0 azureml-telemetry 1.2.0 azureml-tensorboard 1.2.0 azureml-train 1.2.0 azureml-train-automl 1.2.0 azureml-train-automl-client 1.2.0 azureml-train-automl-runtime 1.2.0 azureml-train-core 1.2.0 azureml-train-restclients-hyperdrive 1.2.0 azureml-widgets 1.2.0

@swanderz yes, it is working for me, i am getting the output “Azure ML SDK Version: 1.2.0”

@CESARDELATORRE I have setup a new environment as you suggested and tried again with the automl best deploy model downloaded from AzureML studio but still i am getting the same error.


ModuleNotFoundError Traceback (most recent call last) <ipython-input-3-c7d25df3a7f4> in <module> 3 import numpy as np 4 import pandas as pd ----> 5 import azureml.train.automl 6 from sklearn.externals import joblib 7 from azureml.core.model import Model

~\AppData\Roaming\Python\Python36\site-packages\azureml\train\automl_init_.py in <module> 26 # Suppress the warnings at the import phase. 27 warnings.simplefilter(“ignore”) —> 28 from azureml.train.automl.automlconfig import AutoMLConfig 29 30 try:

ModuleNotFoundError: No module named ‘azureml.train.automl.automlconfig’

@smfahad sorry that’s a really crappy experience. everyone on my team has issues using the azureml-sdk with conda. i’d say once per month things break to the extent that I have to make a new local conda environement. and once a quarter, I have to uninstall and reinstall conda.

Unless @CESARDELATORRE says otherwise, I recommend you make a new environment and run pip install azureml-sdk[automl,interpret]. This will install all the packages required for you to run automl runs (and hopefully use a pickled automl model) both on your local machine as well as submit runs remotely.