Closed PSRCode closed 11 months ago
Hi @PSRCode,
Thanks for reaching out about this. It looks like you may have an older version of the awscrt installed alongside Boto3.
With the release of Boto3 1.33.0, it requires awscrt==0.19.17
for certain functionality. The version of the awscrt you're using doesn't have these available, so the quickest fix is to upgrade the awscrt.
If that's not an option, you can disable boto3 using the awscrt with the BOTO_DISABLE_CRT
environment variable. Let me know if these options aren't sufficient and we can talk more specifics.
Hi @nateprewitt,
Thanks for the quick response. Ok, we will make sure to use awscrt > 0.19.17. I'll report back when I have some time to look into it. What's weird is that we do not define a version for "awscrt" in our requirement.txt so I would expect that we use latest.
Maybe a noob question, how would one should have "known" that we need that version. I would have expected boto3 to "enforce" the version for awscrt.
The awscrt
is an optional dependency that Boto3 will use to optimize functionality if it's present. It's not (and currently can't be) a required dependency for Boto3. It should be kept up to date across AWS products that use it. The main other culprits would be the AWSCLI v2 and the AWS IoT SDK for Python v2.
As far as knowing, this feature has been in place for ~2 years and is intended to be a no-hassle opt-in. That does however make it harder to track for dependency management. If you know you're installing boto3 in conjunction with one of the other tools above, you can change your requirement to boto3[crt]
which will ensure you always have the minimum required awscrt version.
We're discussing options to try to minimize (or ideally eliminate) these kinds of import issues with version mismatches and the awscrt going forward.
We've hit this very issue today on Amazon Linux 2023 that comes with python3-awscrt-0.16.7-1.amzn2023.0.1
.
We can't easily upgrade awscrt
as it's part of Beanstalk AMI, so the only workaround for now is to freeze our version of boto3 to 1.29.7
.
Thanks for letting us know @lisenet. We found the CRT copy on AL2023 was outdated yesterday and are working on a fix to help mitigate that case. We'll provide an update here once that's available.
Same @nateprewitt - the updated crt version is not yet available in the AWS repos. I'm willing to bet this broke a lot of things for a lot of organizations. We had to pin the older version of boto3 as well.
My guess is that since boto3
, awscrt
and AL2023 are all Amazon software, there was no integration test that would include all three of them together. Otherwise this would've been picked up before releasing the code.
That's correct, AL2023 adding the CRT to the default Python setup was not a known integration point before yesterday. A quick note of clarity that boto3 should always be used in a virtualenv to avoid unintentional interactions with the default Python installation, but we're in the process of releasing a change to fix this now.
We expect this issue to be resolved in 1.33.3.
Superb, appreciate the response.
Alright, 1.33.3 is published. I'll leave this open for a bit to gather any feedback/issues but will plan to close this tomorrow if we don't hear back. Thanks everyone for your patience.
Evening. I've also been having an issue. I just updated and I'm still receiving the following error:
ImportError: cannot import name 'S3ResponseError' from 'awscrt.s3' (/usr/local/lib/python3.12/site-packages/awscrt/s3.py)
Installed is the following:
pip freeze | grep awscrt -------> awscrt==0.19.18
pip freeze | grep boto3. -------> boto3==1.33.3
It's probably me, however all was good last week.
Many thanks for any help you could provide.
Hi @hsec, yes this was from a change made yesterday. What version of s3transfer do you have installed? If it's not the latest, 0.8.2
you will still have this issue.
Hi. Thank you for responding. I have 0.8.1. I ran pip install s3transfer>=0.8.2, but no update was available.
0.8.2 should be available on PyPI.
Also to double check from what you wrote above, you're using pip freeze
to display versions. Is this error happening locally or on Lambda? S3ResponseError
is available in awscrt>=0.19.11 so the version of CRT being used isn't what's displayed in pip freeze
.
Hi. This error is local. I successfully installed the 0.8.2 version:
Uninstalling s3transfer-0.8.1: Successfully uninstalled s3transfer-0.8.1 Successfully installed s3transfer-0.8.2
and the previous error has gone away.
I do however now get a S3ResponseError:
ImportError: cannot import name 'S3ResponseError' from 'awscrt.s3' (/usr/local/lib/python3.12/site-packages/awscrt/s3.py)
Perhaps I'm doing something incorrectly.
Do I need to update all of the components to the latest version?
You'll either need everything with the current requirements or the older ones. You won't be able to mix old and new. If you start a fresh virtualenv and pip install boto3[crt]
are you still getting the error?
i.e.
python -m venv .venv
source .venv/bin/activate
python -m pip install "boto3[crt]"
python -c 'import awscrt;import boto3;import botocore;import s3transfer;print(f"Boto3: {boto3.__version__}, Botocore: {botocore.__version__}, S3Transfer: {s3transfer.__version__}, CRT: {awscrt.__version__}")'
If the above still fails, you may try these one at a time:
python -c 'import awscrt; print(f"CRT: {awscrt.__version__}")'
python -c 'import boto3; print(f"Boto3: {boto3.__version__}")'
python -c 'import botocore; print(f"Botocore: {botocore.__version__}")'
python -c 'import s3transfer; print(f"Botocore: {botocore.__version__}")'
Unfortunately, I'm still getting the same error.
What version of the modules (in their entirety), still work, and wha would be the besrt way to about that?
Many thanks in advance.
Good morning. I uninstalled boto3 (1.33.3) and installed version 1.33.4 and all is good again. Thank you again for your patience and rapid response.
Great to hear, @hsec. I'm going to put this in auto-resolve since the original issue is no longer reproducible and we haven't heard back on further issues in the last 24 hours.
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Describe the bug
Hi,
Since Boto3 v1.33.0 we see a failure to import the following from our code application:
from boto3.s3.transfer import TransferConfig
Resulting in the following redacted Traceback:
The same import is working fine on 1.29.7.
Looking at the change log not much seems to be related apart from this:
* feature:``s3``: Boto3 will now opt into using the awscrt on select EC2 instance types for s3 transfers.
For now we will freeze our version locally to 1.29.7.
Cheers
Expected Behavior
The import should work.
Current Behavior
The import is broken.
Reproduction Steps
from boto3.s3.transfer import TransferConfig
Possible Solution
No response
Additional Information/Context
No response
SDK version used
1.33.0/1
Environment details (OS name and version, etc.)
Ubuntu 22.04.2