0

While implementing aws textract Analyse Expense asynchronous api using boto3 for python, I'm getting error as

'Textract' object has no attribute 'start_expense_analysis'.

on the other hand, start_document_text_detection is working fine for me in the same environment.

Code:

def startAnalyseJob(s3BucketName, objectName):
    textract = boto3.client('textract')
    response = textract.start_expense_analysis(
    DocumentLocation={
        'S3Object': {
            'Bucket': s3BucketName,
            'Name': objectName
        }
    })
    return response["JobId"]

jobId = startAnalyseJob(bucket, key)

Error:

[ERROR] AttributeError: 'Textract' object has no attribute 'start_expense_analysis'

codeq09
  • 1
  • 1
  • what could be the possible reason? I'm running it on lambda function with SNS, S3, textract access provided. I'm in urgent need of help. Thanks in advance. – codeq09 Jan 26 '22 at 00:05
  • Instead of using the raw Textract API, I can suggest you take a look at the `amazon-textract-textractor` package, it simplifies a lot calling and parsing the json output. Here is an AnalyzeExpense tutorial that you might find useful: https://aws-samples.github.io/amazon-textract-textractor/notebooks/using_analyze_expense.html – Thomas Mar 03 '23 at 06:35

1 Answers1

1

This errors occur when attempting to call an AWS service or AWS API that requires the latest version of the SDK. Try to upgrade your installation of Boto3 with the following commands:

pip install --upgrade botocore
pip install --upgrade boto3
Tyler
  • 511
  • 5
  • 10
  • Thanks for your response, it worked. these are the versions required, boto3 version:1.20.43 botocore version:1.23.43 – codeq09 Jan 26 '22 at 03:27