AttributeError: 'Template' object has no attribute 'add_description'
robotichead opened this issue · 8 comments
Context
Setup of a Django environment for deployment onto AWS Lambda. Had the following pip packages installed pip install NearBeach zappa pymysql django-storages cryptography
Ran the following command zappa update
to update my live environment.
Expected Behavior
Zappa to deploy the site correctly.
Actual Behavior
Failed to deploy. With the following errors (pulled from my terminal)
Updating Lambda function code..
Updating Lambda function configuration..
Oh no! An error occurred! :(
==============
Traceback (most recent call last):
File "/home/ubuntu/clients/zappa_test/venv/lib/python3.6/site-packages/zappa/cli.py", line 2785, in handle
sys.exit(cli.handle())
File "/home/ubuntu/clients/zappa_test/venv/lib/python3.6/site-packages/zappa/cli.py", line 510, in handle
self.dispatch_command(self.command, stage)
File "/home/ubuntu/clients/zappa_test/venv/lib/python3.6/site-packages/zappa/cli.py", line 557, in dispatch_command
self.update(self.vargs['zip'], self.vargs['no_upload'])
File "/home/ubuntu/clients/zappa_test/venv/lib/python3.6/site-packages/zappa/cli.py", line 993, in update
endpoint_configuration=self.endpoint_configuration
File "/home/ubuntu/clients/zappa_test/venv/lib/python3.6/site-packages/zappa/core.py", line 2106, in create_stack_template
self.cf_template.add_description('Automatically generated with Zappa')
AttributeError: 'Template' object has no attribute 'add_description'
==============
Possible Fix
As discussed on the stackoverflow - https://stackoverflow.com/questions/68391621/zappa-deploy-fails-with-attributeerror-template-object-has-no-attribute-add - the error looks like it has something to do with the NEW troposphere.
Running the following command (i.e. downgrading the troposphere) worked for me: pip install troposphere==2.7.1
Your Environment
- Zappa version used: 0.53.0
- Operating System and Python version: 3.6.9
- The output of
pip freeze
:
argcomplete==1.12.3
asgiref==3.4.1
boto3==1.18.1
botocore==1.21.1
certifi==2021.5.30
cffi==1.14.6
cfn-flip==1.2.3
charset-normalizer==2.0.3
click==8.0.1
cryptography==3.4.7
Django==3.2.5
django-storages==1.11.1
durationpy==0.5
future==0.18.2
hjson==3.0.2
idna==3.2
importlib-metadata==4.6.1
jmespath==0.10.0
kappa==0.6.0
NearBeach==0.28.9.1
pep517==0.11.0
Pillow==8.3.1
pip-tools==6.2.0
placebo==0.9.0
pycparser==2.20
PyMySQL==1.0.2
python-dateutil==2.6.1
python-slugify==5.0.2
pytz==2021.1
PyYAML==5.4.1
requests==2.26.0
s3transfer==0.5.0
simplejson==3.17.3
six==1.16.0
sqlparse==0.4.1
text-unidecode==1.3
toml==0.10.2
tomli==1.0.4
tqdm==4.61.2
troposphere==2.7.1
typing-extensions==3.10.0.0
urllib3==1.26.6
Werkzeug==0.16.1
wsgi-request-logger==0.4.6
zappa==0.53.0
zipp==3.5.0
- Link to your project (optional): https://github.com/robotichead/NearBeach
I experienced this exact issue this morning. Your quick fix solved my problem. Thank you!
Same here, using zappa==0.47.1
Just downgrade to troposphere==2.7.1
and it worked.
Thanks
@Anjalibhatt As said, downgrading to troposphere==2.7.1
will fix it. This is on zappa latest version.
I met the same error in zappa 0.53.0.
but, I resolved.
I use pipenv
, so executed below
pipenv install zappa==0.52.0
pipenv install troposphere==2.7.1
important! zappa update dev
does not make sense.
Finally, I ran below and succeeded :>
zappa undeploy dev
zappa deploy dev
As mentioned in this stackoverflow answer,
Since version 3.0.0, the package troposphere removed the deprecated Template methods (see the changelog).
Breaking changes: * Python 3.6+ (Python 2.x and earlier Python 3.x support is now deprecated due to Python EOL) * Remove previously deprecated Template methods.
The above issue can be fixed by adding troposphere<3 in the requirements file.
Is there any update on this fix? The troposphere solution was working for some time, but now troposphere<3
fails due to use_2to3
with the following error:
Running setup.py install for troposphere ... -� �error
ERROR: Command errored out with exit status 1:
command: /home/circleci/tmp/venv/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ex_p9mes/troposphere_eea0d5a3f8ef4e01a1e32315a1ff4d50/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ex_p9mes/troposphere_eea0d5a3f8ef4e01a1e32315a1ff4d50/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-_rajpc5d/install-record.txt --single-version-externally-managed --compile --install-headers /home/circleci/tmp/venv/include/site/python3.6/troposphere
cwd: /tmp/pip-install-ex_p9mes/troposphere_eea0d5a3f8ef4e01a1e32315a1ff4d50/
Complete output (1 lines):
error in troposphere setup command: use_2to3 is invalid.
----------------------------------------
ERROR: Command errored out with exit status 1: /home/circleci/tmp/venv/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ex_p9mes/troposphere_eea0d5a3f8ef4e01a1e32315a1ff4d50/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ex_p9mes/troposphere_eea0d5a3f8ef4e01a1e32315a1ff4d50/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-_rajpc5d/install-record.txt --single-version-externally-managed --compile --install-headers /home/circleci/tmp/venv/include/site/python3.6/troposphere Check the logs for full command output.
This also seems to be a consistent issue on all projects using use_2to3
due to some recent breaking changes on setuptools
https://setuptools.readthedocs.io/en/latest/history.html#breaking-changes
However the issue is now we can resolve the use_2to3
error by updating the troposphere version but then we're back to the error at the beginning of this thread.
Anyone have any advice?
Also is there any update on getting the core of this issue fixed?
UPDATE
I was able to find a workaround for still using troposphere<3
by also adding setuptools==57.5.0
. So I have both the following in my requirements:
setuptools==57.5.0
troposphere<3
zappa==0.53.0