Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing MLClient leads to error "ImportError: cannot import name '_T' from 'marshmallow.fields' " #39047

Closed
OKazanskyi opened this issue Jan 6, 2025 · 9 comments · Fixed by #39053
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Machine Learning needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@OKazanskyi
Copy link

  • Package Name: azure-ai-ml
  • Package Version: 1.23.0
  • Operating System: ML Studio, Compute Standard_A2_v2
  • Python Version: Python3.8 - AzureML

Describe the bug
When I run command from azure.ai.ml import MLClient I get an error ImportError: cannot import name '_T' from 'marshmallow.fields' (/anaconda/envs/azureml_py38/lib/python3.10/site-packages/marshmallow/fields.py)

To Reproduce
Steps to reproduce the behavior:

  1. Run the Lab 10 https://github.com/MicrosoftLearning/mslearn-azure-ml.git
    I tried remove resource group and install it back, restart the compute and reinstall the library. Nothing helped

Expected behavior
Library MLClient should be successfully loaded

Screenshots
NA

Additional context
The full error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[4], line 1
----> 1 from azure.ai.ml import MLClient

File /anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/ai/ml/__init__.py:11
      8 from typing import Any, Optional
     10 # from .entities._builders.parallel_func import parallel
---> 11 from azure.ai.ml.entities._inputs_outputs import Input, Output
     13 from ._ml_client import MLClient
     14 from ._utils._logger_utils import initialize_logger_info

File /anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/ai/ml/entities/__init__.py:18
     15 from azure.ai.ml._restclient.v2022_10_01.models import CreatedByType
     16 from azure.ai.ml._restclient.v2022_10_01_preview.models import UsageUnit
---> 18 from ._assets._artifacts._package.base_environment_source import BaseEnvironment
     19 from ._assets._artifacts._package.inferencing_server import (
     20     AzureMLBatchInferencingServer,
     21     AzureMLOnlineInferencingServer,
   (...)
     24     TritonInferencingServer,
     25 )
     26 from ._assets._artifacts._package.model_configuration import ModelConfiguration

File /anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/ai/ml/entities/_assets/__init__.py:9
      5 __path__ = __import__("pkgutil").extend_path(__path__, __name__)
      8 from ._artifacts.artifact import Artifact
----> 9 from ._artifacts.code import Code
     10 from ._artifacts.data import Data
     11 from ._artifacts.index import Index

File /anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/ai/ml/entities/_assets/_artifacts/code.py:10
      7 from typing import Any, Dict, Optional, Union
      9 from azure.ai.ml._restclient.v2022_05_01.models import CodeVersionData, CodeVersionDetails
---> 10 from azure.ai.ml._schema import CodeAssetSchema
     11 from azure.ai.ml._utils._arm_id_utils import AMLVersionedArmId
     12 from azure.ai.ml._utils._asset_utils import IgnoreFile, get_content_hash, get_content_hash_version, get_ignore_file

File /anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/ai/ml/_schema/__init__.py:7
      1 # ---------------------------------------------------------
      2 # Copyright (c) Microsoft Corporation. All rights reserved.
      3 # ---------------------------------------------------------
      5 __path__ = __import__("pkgutil").extend_path(__path__, __name__)
----> 7 from ._data_import import DataImportSchema
      8 from ._sweep import SweepJobSchema
      9 from .assets.code_asset import AnonymousCodeAssetSchema, CodeAssetSchema

File /anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/ai/ml/_schema/_data_import/__init__.py:7
      1 # ---------------------------------------------------------
      2 # Copyright (c) Microsoft Corporation. All rights reserved.
      3 # ---------------------------------------------------------
      5 __path__ = __import__("pkgutil").extend_path(__path__, __name__)
----> 7 from .data_import import DataImportSchema
      9 __all__ = ["DataImportSchema"]

File /anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/ai/ml/_schema/_data_import/data_import.py:9
      1 # ---------------------------------------------------------
      2 # Copyright (c) Microsoft Corporation. All rights reserved.
      3 # ---------------------------------------------------------
      4 
      5 # pylint: disable=unused-argument
      7 from marshmallow import post_load
----> 9 from azure.ai.ml._schema.core.fields import NestedField
     10 from azure.ai.ml._schema.job.input_output_entry import DatabaseSchema, FileSystemSchema
     11 from azure.ai.ml._utils._experimental import experimental

File /anaconda/envs/azureml_py38/lib/python3.10/site-packages/azure/ai/ml/_schema/core/fields.py:19
     17 from marshmallow import RAISE, fields
     18 from marshmallow.exceptions import ValidationError
---> 19 from marshmallow.fields import _T, Field, Nested
     20 from marshmallow.utils import FieldInstanceResolutionError, from_iso_datetime, resolve_field_instance
     22 from ..._utils._arm_id_utils import AMLVersionedArmId, is_ARM_id_for_resource, parse_name_label, parse_name_version

ImportError: cannot import name '_T' from 'marshmallow.fields' (/anaconda/envs/azureml_py38/lib/python3.10/site-packages/marshmallow/fields.py)
@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jan 6, 2025
@O-EAI
Copy link

O-EAI commented Jan 7, 2025

Getting same thing here, this is the issue: microsoft/promptflow#3902

@iamrk04
Copy link

iamrk04 commented Jan 7, 2025

This is actively being fixed. Here is the PR covering the fix. We just need to wait for the release of azure-ai-ml==1.23.1.

If you need to solve this immediately, try installing an older version of this package, For example, run the following command in the env: pip install azure-ai-ml==1.22.4. This should fix the issue.

Thanks!

@xiangyan99 xiangyan99 added Machine Learning Service Attention Workflow: This issue is responsible by Azure service team. and removed needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Jan 7, 2025
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Jan 7, 2025
Copy link

github-actions bot commented Jan 7, 2025

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/azure-ml-sdk @azureml-github.

@OKazanskyi
Copy link
Author

I got the same error after uninstalling and installing azure-ai-ml==1.22.4

@apsonawane
Copy link

Still getting the same error after installing azure-ai-ml==1.22.4
Installing marshmallow==3.23.2
Installing az extension ml version 2.32.4

@iamrk04
Copy link

iamrk04 commented Jan 8, 2025

Hi @OKazanskyi ,

the new version of azure-ai-ml, with the fix, has been released. Please run the following to upgrade it: pip install azure-ai-ml --upgrade. This helped resolve the issue at my end.

Thanks!

@lambdakris
Copy link

FYI, this is affecting the azure-ai-evaluation package as well.

@xavimf87
Copy link

It worked with azure-ai-ml==1.23.1

@ncclementi
Copy link

@OKazanskyi any chance that this changes make it into a release in that can be installed with conda?

Looks like the last conda release was 2 months ago see https://anaconda.org/Microsoft/azure-ai-ml and the PR is broken in the feedstock, conda-forge/azure-ai-ml-feedstock#29 any chance someone can take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Machine Learning needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants