ThomasWhite-1678 avatar image
0 Votes"
ThomasWhite-1678 asked ThomasWhite-1678 commented

docs = [doc for doc in result if not doc.is_error] RETURNING 'NoneType' object has no attribute 'errors'

Hi there,

I'm using text_analytics_client.begin_analyze_healthcare_entities and am getting this error on line 14: 'NoneType' object has no attribute 'errors'.

Anyone else experiencing this issue? Guidance?

from azure.core.credentials import AzureKeyCredential
from import TextAnalyticsClient

credential = AzureKeyCredential("00000000000000000000000")

text_analytics_client = TextAnalyticsClient(endpoint, credential)

documents = ["Subject is taking 100mg of ibuprofen twice daily"]

poller = text_analytics_client.begin_analyze_healthcare_entities(documents)
result = poller.result()

docs = [doc for doc in result if not doc.is_error]

print("Results of Healthcare Entities Analysis:")
for idx, doc in enumerate(docs):
for entity in doc.entities:
print("Entity: {}".format(entity.text))
print("...Normalized Text: {}".format(entity.normalized_text))
print("...Category: {}".format(entity.category))
print("...Subcategory: {}".format(entity.subcategory))
print("...Offset: {}".format(entity.offset))
print("...Confidence score: {}".format(entity.confidence_score))
if entity.data_sources is not None:
print("...Data Sources:")
for data_source in entity.data_sources:
print("......Entity ID: {}".format(data_source.entity_id))
print("......Name: {}".format(
if entity.assertion is not None:
print("......Conditionality: {}".format(entity.assertion.conditionality))
print("......Certainty: {}".format(entity.assertion.certainty))
print("......Association: {}".format(entity.assertion.association))
for relation in doc.entity_relations:
print("Relation of type: {} has the following roles".format(relation.relation_type))
for role in relation.roles:
print("...Role '{}' with entity '{}'".format(, role.entity.text))

· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@ThomasWhite-1678 I believe the client operation in your case returned no result or None. Hence, the subsequent operation failed in this case. Could you try to print the result and check if there is a response for your document after begin_analyze_healthcare_entities()

I have tried the same scenario with my script(attached) and it seems to work fine. You could download this script and rename it to *.py with your keys and endpoint and check if it works.


0 Votes 0 ·
health-test.txt (5.0 KiB)

@ThomasWhite-1678 Did you get a chance to try the scenario again with the attached script?

0 Votes 0 ·

Hi there,

I just tried to run the following as a document in the script you sent:
documents = ["Reconsolidation Therapy With Propranolol as a Novel Treatment for Chronic Pain : a Placebo-controlled Feasibility Study"]

I got the following error:


The following is the activity in screen:

In this sample we will be combing through the prescriptions our pharmacy has fulfilled so we can catalog how much inventory we have
We start out with a list of prescription documents.
The thread 0x2 has exited with code 0 (0x0).
'NoneType' object has no attribute 'errors'
Stack trace:
> File "C:\Users\t_whi\source\repos\WorldTrials\", line 61, in <listcomp>
> docs = [doc for doc in result if not doc.is_error]
> File "C:\Users\t_whi\source\repos\WorldTrials\", line 61, in sample_analyze_healthcare_entities
> docs = [doc for doc in result if not doc.is_error]
> File "C:\Users\t_whi\source\repos\WorldTrials\", line 129, in <module> (Current frame)
> sample_analyze_healthcare_entities()
Loaded ''
Loaded 'azure.core.paging'
Loaded '
Loaded 'runpy'

Thank you for your help!


0 Votes 0 ·
image.png (65.9 KiB)

@ThomasWhite-1678 Could you print result object and check if there is any response? I think the client is returning no response so no doc is available in the loop to print the details. It may be because of invalid key or endpoint setting, printing the result might give more information.

0 Votes 0 ·
Show more comments

0 Answers