Boto3 incompatible with python zip import
See original GitHub issueOne of Python’s useful features is its ability to load modules from a .zip archive (PEP here), allowing you to package up multiple dependencies into a single file.
Boto breaks when trying to import it from a .zip, throwing:
File "C:\code sandbox\boto.zip\boto3\session.py", line 263, in client
File "C:\code sandbox\boto.zip\botocore\session.py", line 799, in create_client
File "C:\code sandbox\boto.zip\botocore\session.py", line 668, in _get_internal_component
File "C:\code sandbox\boto.zip\botocore\session.py", line 870, in get_component
File "C:\code sandbox\boto.zip\botocore\session.py", line 150, in create_default_resolver
File "C:\code sandbox\boto.zip\botocore\loaders.py", line 132, in _wrapper
File "C:\code sandbox\boto.zip\botocore\loaders.py", line 424, in load_data
botocore.exceptions.DataNotFoundError: Unable to load data for: endpoints
How to Reproduce:
- Create a .zip containing boto3 and botocore
- Create a .py file in the same directory as the zip (access keys removed for obvious reasons):
sys.path.insert(0, 'boto.zip')
import boto3
s3 = boto3.client('s3', aws_access_key_id='access_key', aws_secret_access_key='secret_key')
- Run
Tested on Python 3.6.7 boto3 1.9.39 botocore 1.12.39
Issue Analytics
- State:
- Created 5 years ago
- Reactions:24
- Comments:20 (6 by maintainers)
Top Results From Across the Web
Resolve "Unable to import module" errors from Python ... - AWS
I receive an "Unable to import module" error when I try to run my AWS Lambda code in Python. How do I resolve...
Read more >boto3 - PyPI
Boto3 is the Amazon Web Services (AWS) Software Development Kit (SDK) for Python, which allows Python developers to write software that makes use...
Read more >S3 — Boto3 Docs 1.26.34 documentation - AWS
Description: The bucket you tried to create already exists, and you own it. Amazon S3 returns this error in all Amazon Web Services...
Read more >zipimport — Import modules from Zip archives ... - Python Docs
Source code: Lib/zipimport.py This module adds the ability to import Python ... The optional path argument is ignored—it's there for compatibility with the ......
Read more >macos - boto3 python 2.7 ImportError: No module named ...
Try this: PYTHONPATH=/usr/local/lib/python2.7/site-packages python -c 'import boto3; print dir(boto3)' . – Leon. Mar 1, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What are the odds of getting this implemented? Its preventing us from distributing boto3, which makes it very hard to provide a package that depends on it in PySpark.
Hey @dsonavane-rgare I’m trying this without success. Can you elaborate a bit more? This is how I was sending my file and deps (this throws boto3 not found because one of my zipped files uses boto3):
This is what I’ve tried now, based on your example:
and this as well:
Thanks