Install & Compatibility
Where this runs
tested against v1.62.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 2.945s · 246.7MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 17.0s · import 2.768s · 248MB
266MB installed
● package 266MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Workspace
✓ from azureml.core import Workspace
✗ from azureml_train_core.core import Workspace
`azureml-train-core` is an internal package; user-facing classes are typically imported from `azureml.core`.
ScriptRunConfig
✓ from azureml.core import ScriptRunConfig
✗ from azureml.train.runconfig import ScriptRunConfig
The modern and recommended way to configure training runs, superseding many `Estimator` uses.
Environment
✓ from azureml.core import Environment
Used to define the software environment for training runs.
Estimator
✓ from azureml.core.estimator import Estimator
Legacy class for configuring training; largely superseded by `ScriptRunConfig` and `Environment`.
This quickstart demonstrates how to initialize an Azure ML Workspace and define an `Environment` using `azureml.core`, which relies on `azureml-train-core`'s underlying capabilities. It highlights the use of `ScriptRunConfig` for submitting training jobs, which has largely replaced the legacy `Estimator` for many scenarios. Authentication details are expected via environment variables or direct replacement.
import os
from azureml.core import Workspace, ScriptRunConfig, Environment
from azureml.core.conda_dependencies import CondaDependencies
# NOTE: Replace with your actual workspace details or ensure environment variables are set
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "your_subscription_id")
resource_group = os.environ.get("AZURE_RESOURCE_GROUP", "your_resource_group")
workspace_name = os.environ.get("AZURE_WORKSPACE_NAME", "your_workspace_name")
try:
ws = Workspace.get(name=workspace_name, subscription_id=subscription_id, resource_group=resource_group)
print(f"Found workspace {ws.name} at {ws.get_details()['location']}")
except Exception:
print("Could not connect to workspace. Ensure AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP, AZURE_WORKSPACE_NAME env vars are set or replace placeholders.")
# For a real run, you'd create a workspace if not found
# ws = Workspace.create(name=workspace_name, subscription_id=subscription_id, resource_group=resource_group, location='eastus')
# Example: Define an environment
env = Environment('my-training-env')
c_deps = CondaDependencies()
c_deps.add_conda_package('scikit-learn')
c_deps.add_pip_package('azureml-sdk')
env.python.conda_dependencies = c_deps
# Create a dummy training script (e.g., train.py)
# with open('train.py', 'w') as f:
# f.write("""
# import os
# print('Hello from Azure ML training!')
# print(f'Running on compute: {os.environ.get("AML_RUN_ID", "unknown")}')
# """)
# Create a ScriptRunConfig (modern way to submit training)
# src = ScriptRunConfig(source_directory='./',
# script='train.py',
# environment=env,
# compute_target='cpu-cluster') # Replace with actual compute target
# Submit the run (uncomment for actual execution)
# if 'ws' in locals():
# run = ws.submit(src)
# run.wait_for_completion(show_output=True)
# print(f"Run finished with status: {run.get_status()}")
else:
print("Workspace not initialized, skipping run submission example.")
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'azureml.train'
This error occurs when a training script attempts to import a module from `azureml.train` (e.g., `azureml.train.automl` or `azureml.train.hyperdrive`), but the necessary `azureml-train-automl` or a comprehensive `azureml-sdk` package is not installed in the environment where the code is executed. The `azureml-train-core` package alone does not include these sub-modules.
fixInstall the `azureml-train-automl` package, which includes the `azureml.train` sub-modules, or install the full `azureml-sdk` with the `[automl, train]` extras. Ensure `azureml-core` is also updated.
pip install --upgrade azureml-core
pip install --upgrade azureml-train-automl
# Alternatively, for the full SDK:
pip install --upgrade azureml-sdk[automl,train]
Estimator is deprecated. Use the ScriptRunConfig object with your own defined environment or an Azure ML curated environment.
The `Estimator` class and its specialized versions (e.g., `PyTorch` estimator) within `azureml-train-core` are deprecated in favor of the more flexible `ScriptRunConfig` class, which offers better control over environments and execution.
fixMigrate your code from using `Estimator` to `ScriptRunConfig`. Define your environment separately using `azureml.core.Environment` and then pass it to `ScriptRunConfig`.
from azureml.core import Environment, ScriptRunConfig
from azureml.core.compute import ComputeTarget
# Assuming workspace (ws) and compute_target are already defined
# 1. Define your environment (e.g., from a conda file or by adding pip packages)
env = Environment.from_conda_specification(name='my_env', file_path='myenv.yml')
# Or, to add pip packages directly:
# env = Environment(name='my_env')
# conda_dep = CondaDependencies.create(pip_packages=['scikit-learn', 'pandas'])
# env.python.conda_dependencies = conda_dep
# 2. Create ScriptRunConfig
script_config = ScriptRunConfig(
source_directory='./',
script='train.py',
compute_target=compute_target,
environment=env,
arguments=['--data-path', 'data']
)
# 3. Submit the experiment
# experiment.submit(script_config) AttributeError: module 'azureml' has no attribute 'core'
This error typically indicates that the `azureml-core` package is not correctly installed or is an outdated version. It can also occur if a user's Python script is named `azureml.py`, causing a conflict with the actual `azureml` package.
fixFirst, ensure `azureml-core` is installed and up-to-date. If the issue persists, check if any of your Python files are named `azureml.py` or similar, and rename them to avoid namespace collisions.
pip install --upgrade azureml-core
# If a file is named azureml.py, rename it to something like my_azure_script.py
AttributeError: 'RoundTripLoader' object has no attribute 'comment_handling'
This specific error arises due to an incompatibility between certain versions of `azureml-core` and the `ruamel-yaml` package, particularly when `ruamel-yaml` version `0.17.5` or newer is installed.
fixUninstall the problematic `ruamel-yaml` version and install a compatible version, typically within the range `0.15.35` to `0.17.4` (inclusive).
pip uninstall ruamel-yaml
pip install "ruamel-yaml>=0.15.35,<0.17.5"
Upgrade
Version history
1.62.0latest on PyPI · released Feb 25, 2026
Audit
Dependencies
azureml-corerequiredPrimary dependency for Azure ML Workspace interaction and run management.
azureml-telemetryrequiredUsed for telemetry data collection within the SDK.
azureml-pipeline-corerequiredProvides core functionalities for pipeline steps and data flow.