amazon-textract-textractor icon indicating copy to clipboard operation
amazon-textract-textractor copied to clipboard

I am missing something... ~/.aws/config and ~/.aws/credentials

Open chandailrc opened this issue 2 years ago • 3 comments

Hello, I was trying to run examples from this repo. I do not have prior experience with AWS. I am using conda env on Ubuntu 22.04. As per instructions I have installed the package using pip install "amazon-textract-textractor[dev]". Everything got installed without any hitch. Now I wanted to try out the table extractor example. When I try to run: extractor = Textractor(profile_name="default")

I get the error: ProfileNotFound: The config profile (default) could not be found

I found a workaround in one of the issue post: changing the profile_name to region_name

extractor = Textractor(region_name='us-west-2')

document = extractor.analyze_document(
    file_source=image,
    features=[TextractFeatures.TABLES],
    save_image=True
)

Now when I proceed I get the error: NoCredentialsError: Unable to locate credentials

It seems I am missing the ~/.aws/config and ~/.aws/credentials files. Not sure how I was supposed to get them? Do I need to install the aws sdk first?

chandailrc avatar Aug 09 '23 16:08 chandailrc

Yes, Textract is a paid service so in order to be able to use the API you need to be logged in your AWS account. One way to do that is to install the AWS CLI and run aws configure. See https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html

ThomasDelteil avatar Aug 09 '23 17:08 ThomasDelteil

@ThomasDelteil do you know whether there is a way to let the Textractor() initialise without the ~/.aws/configure or aws configure, but via the environment variables? Problem is with lambda functions, I cannot seem to set the aws configure files in my lambdas, right?

LarsKuijpers2 avatar Dec 07 '23 20:12 LarsKuijpers2

You can do that by only providing a region name when instanciating the Textractor object like this. See my reply here: https://github.com/aws-samples/amazon-textract-textractor/issues/280#issuecomment-1823492344

Belval avatar Dec 07 '23 20:12 Belval