0

I could have sworn I used this before and it was working fine. Not sure if my environment changed or I am forgetting something else.

import boto

b = "some_bucket"
key = "some_s3_key"

k = boto.s3.key.Key(b, key)

but now I am getting an error

AttributeError: 'module' object has no attribute 'key'

Am I doing something wrong? This is for

boto            2.49.0
botocore        1.16.7

with python 2

I was going to use k.get_file() and k.set_contents_from_file()

user1179317
  • 2,693
  • 3
  • 34
  • 62

1 Answers1

2

In general it's required to import submodules directly.

Instead of

import boto

Use

import boto.s3.key

Please note that boto has been deprecated for quite some time, the last release was in 2018 and this project is no longer maintained.

You should consider switching over to boto3.

wim
  • 338,267
  • 99
  • 616
  • 750
  • Ok, thanks that woks. Yea I know, I wish. Its a legacy environment and its not easy to update the env (and I dont have rights to :( ) – user1179317 May 24 '22 at 15:53