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
ImportError: cannot import name 'escape' from 'jinja2' #3791
Comments
That's probably the same issue - pallets/flask#4494 |
@arber-od meanwhile, would you be able to install SAM CLI using Linux installer? |
I am having the same issue within our pipelines environment. Docker image: image: python:3.7.4 It seems to be intermittent as if I re-run the build once or twice it works fine. I also ran the same container/commands locally with my code and did not have an issue, so I'm a little confused on what we could do to fix this. I ran into the same issue mentioned above pallets/flask#4494 but it seems like something needs to be fixed in the sam cli build. If it helps, this started happening a week or so ago. |
Thanks for reaching out! I believe this issue is due to the newest versions of jinja2 deprecated the "escape" as referenced in https://jinja.palletsprojects.com/en/3.1.x/changes/#version-3-1-0, https://stackoverflow.com/questions/71718167/importerror-cannot-import-name-escape-from-jinja2 also has some context on this to read about, we will look into how to update our dependency versions to prevent this. Thanks for reporting this and we for sure will try to address this ASAP! |
Meanwhile I believe you can try to install through other methods, or installing in a separate virtual env to see if you can get yourself unblocked for now! Let me know if that works for you! |
Thanks @qingchm . Not a python expert, so there might be a better way here but manually overriding the dependency version of jinja2 works as a stop gap for us until this gets' fixed on the sam cli side.
|
workaround for issue with sam dependencies tracked in aws/aws-sam-cli#3791
workaround for issue with sam dependencies tracked in aws/aws-sam-cli#3791
workaround for issue with sam dependencies tracked in aws/aws-sam-cli#3791
workaround for issue with sam dependencies tracked in aws/aws-sam-cli#3791
workaround for issue with sam dependencies tracked in aws/aws-sam-cli#3791
I believe that this is fixed in the new 1.53.0 release. Please have a try and if you still have any questions or issues feel free to re-open the issue! |
Description:
During sam build we faced an issue:
ImportError: cannot import name 'escape' from 'jinja2' (/usr/local/lib/python3.7/dist-packages/jinja2/init.py)
Steps to reproduce:
sam build
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: 1.43.0-py3-none-any$ sam build
SAM CLI now collects telemetry to better understand customer needs.
You can OPT OUT and disable telemetry collection by setting the
environment variable SAM_CLI_TELEMETRY=0 in your shell.
Thanks for your help!
Learn More: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-telemetry.html
Traceback (most recent call last):
File "/usr/local/bin/sam", line 10, in
sys.exit(cli())
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/samcli/lib/telemetry/metric.py", line 166, in wrapped
raise exception # pylint: disable=raising-bad-type
File "/usr/local/lib/python3.7/dist-packages/samcli/lib/telemetry/metric.py", line 124, in wrapped
return_value = func(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/samcli/lib/utils/version_checker.py", line 41, in wrapped
actual_result = func(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/samcli/cli/main.py", line 87, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/samcli/commands/build/command.py", line 192, in cli
build_image,
File "/usr/local/lib/python3.7/dist-packages/samcli/commands/build/command.py", line 220, in do_cli
from samcli.commands.build.build_context import BuildContext
File "/usr/local/lib/python3.7/dist-packages/samcli/commands/build/build_context.py", line 13, in
from samcli.lib.providers.sam_api_provider import SamApiProvider
File "/usr/local/lib/python3.7/dist-packages/samcli/lib/providers/sam_api_provider.py", line 6, in
from samcli.lib.providers.api_collector import ApiCollector
File "/usr/local/lib/python3.7/dist-packages/samcli/lib/providers/api_collector.py", line 10, in
from samcli.local.apigw.local_apigw_service import Route
File "/usr/local/lib/python3.7/dist-packages/samcli/local/apigw/local_apigw_service.py", line 11, in
from flask import Flask, request
File "/usr/local/lib/python3.7/dist-packages/flask/init.py", line 14, in
from jinja2 import escape
ImportError: cannot import name 'escape' from 'jinja2' (/usr/local/lib/python3.7/dist-packages/jinja2/init.py)
The text was updated successfully, but these errors were encountered: