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 method. So far I've tried both bbfreeze
and py2exe
and both yield the same results. The code in question that causes trouble looks like this:
import boto
#...snip...
fname_base = os.path.basename(fname)
s3 = boto.connect_s3(aws_access_key_id=_aws_key, aws_secret_access_key=_aws_secret_key, is_secure=False);
bucket = s3.get_bucket(_bucket)
key = bucket.new_key(fname_base)
key.set_contents_from_filename(fname)
Compiled with either executable bundling utility and run I get:
Traceback (most recent call last):
File "s3stash.py", line 238, in <module>
sys.exit(main())
File "s3stash.py", line 225, in main
push_file_to_s3(f, options)
File "s3stash.py", line 160, in push_file_to_s3
_push_with_boto(fname)
File "s3stash.py", line 148, in _push_with_boto
s3 = boto.connect_s3(aws_access_key_id=_aws_key, aws_secret_access_key=_aws_secret_key, is_secure=False);
File "boto\__init__.pyo", line 104, in connect_s3
File "zipextimporter.pyo", line 82, in load_module
File "boto\s3\connection.pyo", line 27, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "boto\utils.pyo", line 55, in <module>
File "email\__init__.pyo", line 79, in __getattr__
ImportError: No module named multipart
I'm using ActiveState Python 2.6 on Windows XP SP3. The boto package was installed with:
easy_installer --always-unzip boto
I used the --always-unzip
option based on the information found here about py2exe
having issues with the egg files that were unpacked. Unfortunately the error I get is the same when I use bb-freeze
to build the executable.
The output from py2exe
includes, near the end, the following bit of information:
The following modules appear to be missing
['_scproxy', 'email.Encoders', 'email.MIMEBase', 'email.MIMEMultipart', 'email.MIMEText', 'email.Utils', 'simplejson']
Which lends some hints. I tried methods suggested in other posts to SO where the -i
option was recommended when compiling with py2exe
and unfortunately nothing helped. In those other questions the users were doing their own explicit inclusion of of the email sub-modules. I could not figure how to adapt those solutions to my case unfortunately and just adding them with -i
didn't stop py2exe
from warning me of the missing modules, or the resulting bundled exe from failing with the missing module error.
Can someone help me get this code bundled for redistribution?