AWS data wrangler error: WaiterError: Waiter BucketExists failed: Max attempts exceeded

Question:

I am trying to read data from athena into python’s pandas dataframe. However, I encounter this error

WaiterError: Waiter BucketExists failed: Max attempts exceeded.
Previously accepted state: Matched expected HTTP status code: 404

Do anyone have the same problem when using data wrangler?
This is my code below

import awswrangler as wr
import pandas as pd
wr.athena.read_sql_query('select * from ath_bi_orders limit 10', database='default')
Asked By: user16934888

||

Answers:

I have faced the same issue and resolved it by specifying AWS_DEFAULT_REGION env variable.

Like this.

os.environ['AWS_DEFAULT_REGION'] = 'ap-northeast-1' # specify your AWS region.

Execute it before you throw the query.

Answered By: ken

If you have the AWS CLI installed you can also set the region with aws configure:

> aws configure
AWS Access Key ID [********************]:
AWS Secret Access Key [********************]:
Default region name [None]: us-east-1
Default output format [json]:

This fixed the error for me when I was using AWS datawrangler to run an Athena query.

Answered By: abk

You need to specify the region.

You can do it as @ken did using env var or by setting the default boto3 session like that:

boto3.setup_default_session(region_name=region)

The read_sql_query function uses the default boto3 session if no other session is provided (as mentioned here)

Answered By: HagaiA
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.