-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
boto3 not available in local Python3.6 #2136
Comments
+1 |
3 similar comments
+1 |
+1 |
+1 |
Been meaning to post this, but been a bit swamped. It works fine on sam 0.53.0, so that's where I'm staying for the time being. |
+1 |
+1, not clear how to downgrade to 0.53.0 using Homebrew, reinstalled using pip instead. |
I noticed that the message - "Failed to download a new ...." is actually a false alarm. The "local invoke" actually works without a problem. I have tried this in a totally new virtual machine, and made sure that I did not have any cached images. All of my "local invoke" and "local start-api" worked. May be in the next release, they can remove this false alarm. For now, I think that we can just ignore it. |
@BigMountainTiger Do your lambdas use boto3? If you're not importing boto3, they might work fine without your running into this issue. While the OP is on Mac, I'm on Windows and installed version 1.0.0 on WSL1 the homebrew way set out on the docs page. I also separately installed version 1.0.0 on the Windows side. Both were giving me the same On my WSL1, I uninstalled the homebrew version and installed 0.53.0 using |
Actually a quick try succeeded: _import boto3 def lambda_handler(event, context): s3 = boto3.client('s3') return { It works nicely, although I still see the message - "Failed to download a new amazon/aws-sam-cli-emulation-image-python3.8 ....." with ... SAM CLI, version 1.0.0 |
This should be fixed for all Python invoke images. Please reopen this issue if you see this issue recur. You do not need to upgrade your version of AWS SAM CLI to see the changes on this. However, if you do see the issue recur, please remove your Docker images associated with Python runtime emulation, in case it failed to auto-update. |
@awood45 Still getting this on, sam start api, tried re pulling the docker images |
@awood45 - upgraded to 1.1.0 and it's worse for me. I now get this when I call a locally running API: 'Invoking main.lambda_handler (python3.6)\n' So going back to 0.53.0. Not sure if this is just a new issue or whether it's just aprt of the same thing. |
installed from scratch and getting this same error |
Reopening while we try to reproduce issues with the new images. |
Question for those still seeing issues: Can you please return the output of the following command?
For me, I get the following:
One of our operating theories is that older images are getting cached somehow. The output of this command will help us to confirm/deny that hypothesis. |
@johnc44 Can you give more detailed reproduction instructions? That looks like a separate issue but I'd like to try and reproduce that ASAP. I'm also interested in your |
@awood45 I switched back to 0.53.0 but just to help out I installed 1.0.0 again. This is the result of
And this is the result after installing it:
So yes, It no longer throws the |
@awood45 - just tried upgrading to 1.1.0 again and it is now working. But for reference here's the info you requested: Before upgrading to 1.1.0 again I ran docker images | grep emulation amazon/aws-sam-cli-emulation-image-python3.6 rapid-1.1.0 aeb97e10d7c5 2 days ago 849MB Now I've reinstalled 1.1.0 and done the same, I get the exact same output. To get the error I was using "sam build && sam local start-api -n environment.json -p 3100" Not sure if I was doing something stupid last week, because it looks like it brought down the image. I'll monitor it this afternoon but hopefully whatever it was is fixed. Thanks for your speedy reply and apologies if it was something my end. |
@mbuotidem What kind of credentials are you using when you run local testing? That error does not look like it should be a Docker/image issue, and we've been trying without success to reproduce the error. Any other information you have about how you got that error would be helpful. @johnc44 No worries, do let me know if it returns and we can try to reproduce. |
@awood45 I used AWS IAM credentials. Really I all I did was import boto3 inside app.py of the provided sam-app and then inside lambda_handler, I tried to list buckets with :
Since its not a Docker/image issue, I should probably just create a different issue so as not to derail this thread. |
I'm still getting this issue after upgrading sam 1.0.0 -> 1.1.0
Here are my docker images for emulation.
|
Can you delete your ‘:latest’ tag for the Python 3.7 emulation image and re-download? I believe your image might be cached. |
I have the same issue with
Here is the output of
Did anybody found a workaround? I can put boto3 in my It's clearly written it should be available. https://docs.aws.amazon.com/lambda/latest/dg/lambda-python.html EDIT: My bad I have realized it comes from my PYTHONPATH env variable. |
Closing this issue, as I can no longer reproduce it. |
This appears to repro again with Python 3.8.
Could be related to lambci/docker-lambda#333 if the build images are based on docker-lambda. |
Description
boto3 seems to not be available when running lambda functions locally through
sam local invoke
.Steps to reproduce
This used to work with earlier images.
Observed result
Unable to import module 'app': No module named 'boto3'
Expected result
boto3 is supposed to be available in Lambda environments.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
:SAM CLI, version 1.0.0
Add --debug flag to command you are running
The text was updated successfully, but these errors were encountered: