error on from azure.ai.textanalytics import TextAnalyticsClient

Saiu Luminita 20 Reputation points
2025-05-06T18:24:15.3466667+00:00

Hi

I try to run Python sample for below:

https://learn.microsoft.com/en-us/azure/ai-services/language-service/named-entity-recognition/quickstart?tabs=windows%2Cga-api&pivots=programming-language-python

Got stuck at following:

from azure.ai.textanalytics import TextAnalyticsClient

from azure.core.credentials import AzureKeyCredential

from ._text_analytics_client import TextAnalyticsClient

File "c:\Python\Python313\Lib\site-packages\azure\ai\textanalytics_text_analytics_client.py", line 20, in <module> from ._base_client import TextAnalyticsClientBase, TextAnalyticsApiVersion

File "c:\Python\Python313\Lib\site-packages\azure\ai\textanalytics_base_client.py", line 9, in <module>

from ._generated import TextAnalyticsClient as _TextAnalyticsClient

File "c:\Python\Python313\Lib\site-packages\azure\ai\textanalytics_generated_init_.py", line 9, in <module>

from ._text_analytics_client import TextAnalyticsClient

File "c:\Python\Python313\Lib\site-packages\azure\ai\textanalytics_generated_text_analytics_client.py", line 20,

in <module>

from ._operations_mixin import TextAnalyticsClientOperationsMixin

File "c:\Python\Python313\Lib\site-packages\azure\ai\textanalytics_generated_operations_mixin.py", line 16, in <module>

from .._lro import AnalyzeActionsLROPoller, AnalyzeActionsLROPollingMethod, AnalyzeHealthcareEntitiesLROPoller, AnalyzeHealthcareEntitiesLROPollingMethod

File "c:\Python\Python313\Lib\site-packages\azure\ai\textanalytics_lro.py", line 8, in <module>

from azure.core.polling._poller import PollingReturnType

ImportError: cannot import name 'PollingReturnType' from 'azure.core.polling._poller' (c:\Python\Python313\Lib\site-packages\azure\core\polling_poller.py)

Azure AI Language
Azure AI Language
An Azure service that provides natural language capabilities including sentiment analysis, entity extraction, and automated question answering.
492 questions
0 comments No comments
{count} votes

Accepted answer
  1. Prashanth Veeragoni 4,435 Reputation points Microsoft External Staff Moderator
    2025-05-07T02:22:38.27+00:00

    Hi Saiu Luminita,

    Thanks for sharing error details. You are encountering this error:

    ImportError: cannot import name 'PollingReturnType' from 'azure.core.polling._poller'
    

    This typically indicates a version mismatch between your azure-ai-textanalytics package and the azure-core package, where azure-ai-textanalytics expects a certain version of azure-core that includes PollingReturnType, but your current azure-core version doesn't have it.

    To fix this issue:

    1.Check current versions: Run this in your terminal:

    pip show azure-ai-textanalytics azure-core
    

    2.Upgrade both packages to compatible versions: Use the following command to upgrade to compatible versions:

    pip install --upgrade azure-ai-textanalytics azure-core
    

    As of the latest stable release:

    ·       azure-ai-textanalytics should be v5.3.0 or newer

    ·       azure-core should be v1.26.0 or newer

    3.Verify your environment is clean: If you're using a global Python installation, it might be better to use a virtual environment to avoid conflicting packages:

    python -m venv myenv
    myenv\Scripts\activate
    pip install azure-ai-textanalytics
    

    This happens because:

    The PollingReturnType class was introduced in a newer version of azure-core. If you're using an older version of azure-core, it won't have that class, and azure-ai-textanalytics which expects it will fail to import it.

    Hope this helps. Do let us know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    Thank you!

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Saiu Luminita 20 Reputation points
    2025-05-06T18:25:04.04+00:00

    updated above

    0 comments No comments

  2. Saiu Luminita 20 Reputation points
    2025-05-07T18:07:24.4633333+00:00
    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.