aws-samples / amazon-textract-textractor

Analyze documents with Amazon Textract and generate output in multiple formats.
Apache License 2.0
404 stars 145 forks source link

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

Open chandailrc opened 1 year ago

chandailrc commented 1 year ago

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?

ThomasDelteil commented 1 year ago

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

LarsKuijpers2 commented 11 months ago

@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?

Belval commented 11 months ago

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