Skip to content Skip to sidebar Skip to footer

How To Compile Python Code That Uses Boto To Access S3?

I'm trying to compile a simple Python program, that uploads files to an S3 bucket using the boto package, in to a single, redistributable .exe file. I'm open to any compilation met

Solution 1:

I actually got this to work. The answer was to ditch boto and use the poster library instead. I still use boto to generate a signed policy and the necessary form fields for POST I do via poster, but the actual executable that does the POST only includes poster now. With just poster in the mix, py2exe doesn't have any issues creating a standalone executable for me for redistribution.

Solution 2:

I know this is an old question, but I had the same problem and fixed it while still using py2exe and py2app. Just use the 'packages' option instead of the 'includes' option in your setup.py:

extra = {}
mainscript = "foo/__main__.py"ifis_os_x():
    extra["setup_requires"] =['py2app']
    extra["app"] = [mainscript]
    extra["options"] = { "py2app": {
        "packages": ['email'],
        }                                       
    }

elif is_windows():
    extra["setup_requires"] =['py2exe']
    extra['console'] = [mainscript]
    extra['options'] = {'py2exe': {
        # Includes that py2exe doesn't include automatically'packages': ['email'],
       }
    }

setup(
    # snip
    ** extra
)   

Hope that helps.

Solution 3:

I've managed to create working exe with boto & py2exe

Add to your script.py

from email.mime.multipartimportMIMEMultipartfrom email.mime.textimportMIMEText

Next error is with HTTPS connection, it seems that py2exe is "hiding" cert file somehow.. The way to fix this is 1) use HTTP OR 2) dont check certs

1) HTTP

conn = boto.connect_dynamodb(
    aws_access_key_id = ' ',
    aws_secret_access_key = ' ', 
    is_secure = False)

"is_secure = False" is crutial

2) DONT CHECK CERTS

conn = boto.connect_dynamodb(
    aws_access_key_id = ' ',
    aws_secret_access_key = ' ', 
    is_secure = True, 
    validate_certs = False)

"validate_certs = False" is crutial

If someone figures out how to fix error in cert validation, please reply !

Post a Comment for "How To Compile Python Code That Uses Boto To Access S3?"