aws-cloudformation / cloudformation-cli

The CloudFormation Provider Development Toolkit allows you to author your own resource providers and modules that can be used by CloudFormation.
Apache License 2.0
318 stars 161 forks source link

*cfn init* fails with unhandled ContextualVersionConflict for MarkupSafe #899

Closed greg5123334 closed 1 year ago

greg5123334 commented 2 years ago

Abstract

After having installed Cloudformation CLI as per docs:

pip3 install cloudformation-cli cloudformation-cli-java-plugin cloudformation-cli-go-plugin cloudformation-cli-python-plugin cloudformation-cli-typescript-plugin

I am encountering an unhandled exception. details to follow.


Deep Dive

$ python3 -m venv .venv
$ source .venv/bin/activate
(.venv) $ pip3 install cloudformation-cli cloudformation-cli-java-plugin clo
udformation-cli-go-plugin cloudformation-cli-python-plugin cloudformation-cli-typescript-plugin
Collecting cloudformation-cli
 Using cached cloudformation_cli-0.2.25-py3-none-any.whl (115 kB)
Collecting cloudformation-cli-java-plugin
 Using cached cloudformation_cli_java_plugin-2.0.12-py3-none-any.whl (68 kB)
Collecting cloudformation-cli-go-plugin
 Using cached cloudformation_cli_go_plugin-2.0.4-py3-none-any.whl (15 kB)
Collecting cloudformation-cli-python-plugin
 Using cached cloudformation_cli_python_plugin-2.1.5-py3-none-any.whl (20 kB)
Collecting cloudformation-cli-typescript-plugin
 Using cached cloudformation_cli_typescript_plugin-1.0.1-py3-none-any.whl (18 kB)
Collecting hypothesis>=4.32
 Using cached hypothesis-6.54.4-py3-none-any.whl (390 kB)
Collecting colorama>=0.4.1
 Downloading colorama-0.4.5-py2.py3-none-any.whl (16 kB)
Collecting PyYAML<6.0,>=5.1
 Downloading PyYAML-5.4.1-cp38-cp38-manylinux1_x86_64.whl (662 kB)
    |████████████████████████████████| 662 kB 8.4 MB/s
Collecting Jinja2==2.11.3
 Using cached Jinja2-2.11.3-py2.py3-none-any.whl (125 kB)
Collecting markupsafe==2.0.1
 Using cached MarkupSafe-2.0.1-cp38-cp38-manylinux2010_x86_64.whl (30 kB)
Collecting pytest>=4.5.0
 Using cached pytest-7.1.2-py3-none-any.whl (297 kB)
Collecting ordered-set>=4.0.2
 Using cached ordered_set-4.1.0-py3-none-any.whl (7.6 kB)
Collecting pytest-localserver>=0.5.0
 Using cached pytest_localserver-0.7.0-py3-none-any.whl (19 kB)
Collecting cfn-flip>=1.2.3
 Using cached cfn_flip-1.3.0-py3-none-any.whl (21 kB)
Collecting boto3>=1.10.20
 Using cached boto3-1.24.63-py3-none-any.whl (132 kB)
Collecting jsonschema<4.0,>=3.0.1
 Downloading jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
    |████████████████████████████████| 56 kB 2.3 MB/s
Collecting cfn-lint>=0.43.0
 Using cached cfn_lint-0.63.2-py3-none-any.whl (9.0 MB)
Collecting docker>=4.3.1
 Using cached docker-6.0.0-py3-none-any.whl (147 kB)
Collecting Werkzeug>=0.15
 Using cached Werkzeug-2.2.2-py3-none-any.whl (232 kB)
Processing /home/user/.cache/pip/wheels/45/24/5f/e04b86d3fb09ba980e1ad80697dc17adc5d456a0ae746176f0/nested_lookup-0.2.25-py3-none-any.whl
Collecting pytest-random-order>=1.0.4
 Using cached pytest_random_order-1.0.4-py3-none-any.whl (10 kB)
Collecting requests>=2.22
 Downloading requests-2.28.1-py3-none-any.whl (62 kB)
    |████████████████████████████████| 62 kB 300 kB/s
Collecting semver>=2.9.0
 Using cached semver-2.13.0-py2.py3-none-any.whl (12 kB)
Collecting types-dataclasses>=0.1.5
 Using cached types_dataclasses-0.6.6-py3-none-any.whl (2.9 kB)
Processing /home/user/.cache/pip/wheels/d5/50/ed/bd3a28b4c2c42777685d876d17fcaee69fcbc2d15cd7382af2/zipfile38-0.0.3-py3-none-any.whl
Collecting sortedcontainers<3.0.0,>=2.1.0
 Using cached sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)
Collecting exceptiongroup>=1.0.0rc8; python_version < "3.11"
 Downloading exceptiongroup-1.0.0rc9-py3-none-any.whl (12 kB)
Collecting attrs>=19.2.0
 Using cached attrs-22.1.0-py2.py3-none-any.whl (58 kB)
Collecting pluggy<2.0,>=0.12
 Using cached pluggy-1.0.0-py2.py3-none-any.whl (13 kB)
Collecting packaging
 Using cached packaging-21.3-py3-none-any.whl (40 kB)
Collecting iniconfig
 Using cached iniconfig-1.1.1-py2.py3-none-any.whl (5.0 kB)
Collecting py>=1.8.2
 Using cached py-1.11.0-py2.py3-none-any.whl (98 kB)
Collecting tomli>=1.0.0
 Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting six
 Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting Click
 Downloading click-8.1.3-py3-none-any.whl (96 kB)
    |████████████████████████████████| 96 kB 3.0 MB/s
Collecting s3transfer<0.7.0,>=0.6.0
 Using cached s3transfer-0.6.0-py3-none-any.whl (79 kB)
Collecting botocore<1.28.0,>=1.27.63
 Using cached botocore-1.27.63-py3-none-any.whl (9.1 MB)
Collecting jmespath<2.0.0,>=0.7.1
 Using cached jmespath-1.0.1-py3-none-any.whl (20 kB)
Collecting pyrsistent>=0.14.0
 Downloading pyrsistent-0.18.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (119 kB)
    |████████████████████████████████| 119 kB 2.4 MB/s
Requirement already satisfied: setuptools in ./.venv/lib/python3.8/site-packages (from jsonschema<4.0,>=3.0.1->cloudformation-cli) (44.0.0)
Collecting jschema-to-python~=1.2.3
 Using cached jschema_to_python-1.2.3-py3-none-any.whl (10 kB)
Collecting aws-sam-translator>=1.50.0
 Using cached aws_sam_translator-1.50.0-py3-none-any.whl (232 kB)
Collecting jsonpatch
 Downloading jsonpatch-1.32-py2.py3-none-any.whl (12 kB)
Collecting networkx~=2.4
 Using cached networkx-2.8.6-py3-none-any.whl (2.0 MB)
Collecting sarif-om~=1.0.4
 Using cached sarif_om-1.0.4-py3-none-any.whl (30 kB)
Collecting junit-xml~=1.9
 Using cached junit_xml-1.9-py2.py3-none-any.whl (7.1 kB)
Collecting urllib3>=1.26.0
 Using cached urllib3-1.26.12-py2.py3-none-any.whl (140 kB)
Collecting websocket-client>=0.32.0
 Using cached websocket_client-1.4.0-py3-none-any.whl (54 kB)
Collecting charset-normalizer<3,>=2
 Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Collecting certifi>=2017.4.17
 Downloading certifi-2022.6.15-py3-none-any.whl (160 kB)
    |████████████████████████████████| 160 kB 18.6 MB/s
Collecting idna<4,>=2.5
 Downloading idna-3.3-py3-none-any.whl (61 kB)
    |████████████████████████████████| 61 kB 4.1 MB/s
Collecting pyparsing!=3.0.5,>=2.0.2
 Using cached pyparsing-3.0.9-py3-none-any.whl (98 kB)
Collecting python-dateutil<3.0.0,>=2.1
 Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting pbr
 Using cached pbr-5.10.0-py2.py3-none-any.whl (112 kB)
Collecting jsonpickle
 Using cached jsonpickle-2.2.0-py2.py3-none-any.whl (39 kB)
Collecting jsonpointer>=1.9
 Downloading jsonpointer-2.3-py2.py3-none-any.whl (7.8 kB)
ERROR: werkzeug 2.2.2 has requirement MarkupSafe>=2.1.1, but you'll have markupsafe 2.0.1 which is incompatible.
Installing collected packages: sortedcontainers, exceptiongroup, attrs, hypothesis, colorama, PyYAML, markupsafe, Jinja2, pluggy, pyparsing, packaging, iniconfig, py, tomli, pytest, ordered-set, Werkzeug, pytest-localserver, six, Click, cfn-flip, jmespath, python-dateutil, urllib3, botocore, s3transfer, boto3, pyrsistent, jsonschema, pbr, jsonpickle, jschema-to-python, aws-sam-translator, jsonpointer, jsonpatch, networkx, sarif-om, junit-xml, cfn-lint, websocket-client, charset-normalizer, certifi, idna, requests, docker, nested-lookup, pytest-random-order, cloudformation-cli, cloudformation-cli-java-plugin, semver, cloudformation-cli-go-plugin, types-dataclasses, cloudformation-cli-python-plugin, zipfile38, cloudformation-cli-typescript-plugin
Successfully installed Click-8.1.3 Jinja2-2.11.3 PyYAML-5.4.1 Werkzeug-2.2.2 attrs-22.1.0 aws-sam-translator-1.50.0 boto3-1.24.63 botocore-1.27.63 certifi-2022.6.15 cfn-flip-1.3.0 cfn-lint-0.63.2 charset-normalizer-2.1.1 cloudformation-cli-0.2.25 cloudformation-cli-go-plugin-2.0.4 cloudformation-cli-java-plugin-2.0.12 cloudformation-cli-python-plugin-2.1.5 cloudformation-cli-typescript-plugin-1.0.1 colorama-0.4.5 docker-6.0.0 exceptiongroup-1.0.0rc9 hypothesis-6.54.4 idna-3.3 iniconfig-1.1.1 jmespath-1.0.1 jschema-to-python-1.2.3 jsonpatch-1.32 jsonpickle-2.2.0 jsonpointer-2.3 jsonschema-3.2.0 junit-xml-1.9 markupsafe-2.0.1 nested-lookup-0.2.25 networkx-2.8.6 ordered-set-4.1.0 packaging-21.3 pbr-5.10.0 pluggy-1.0.0 py-1.11.0 pyparsing-3.0.9 pyrsistent-0.18.1 pytest-7.1.2 pytest-localserver-0.7.0 pytest-random-order-1.0.4 python-dateutil-2.8.2 requests-2.28.1 s3transfer-0.6.0 sarif-om-1.0.4 semver-2.13.0 six-1.16.0 sortedcontainers-2.4.0 tomli-2.0.1 types-dataclasses-0.6.6 urllib3-1.26.12 websocket-client-1.4.0 zipfile38-0.0.3
$cfn init
=== Unhandled exception ===
Please report this issue to the team.
Issue tracker: github.com/aws-cloudformation/cloudformation-cli/issues
Please include this information:
Traceback (most recent call last):
  File "/<path_to_workdir>/sandbox/.venv/lib/python3.8/site-packages/rpdk/core/cli.py", line 83, in main
    init_setup_subparser(subparsers, parents)
  File "/<path_to_workdir>/sandbox/.venv/lib/python3.8/site-packages/rpdk/core/init.py", line 171, in setup_subparser
    language_setup_subparser()(language_subparsers, [base_subparser])
  File "/<path_to_workdir>/sandbox/.venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2442, in load
    self.require(*args, **kwargs)
  File "/<path_to_workdir>/sandbox/.venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2465, in require
    items = working_set.resolve(reqs, env, installer, extras=self.extras)
  File "/<path_to_workdir>/sandbox/.venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 791, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (MarkupSafe 2.0.1 (/<path_to_workdir>/sandbox/.venv/lib/python3.8/site-packages), Requirement.parse('MarkupSafe>=2.1.1'), {'werkzeug', 'Werkzeug'})

Additional Info

(WSL on Windows 10)

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:        20.04
Codename:       focal
pip3 --version
pip 20.0.2 from /<workdir>/sandbox/.venv/lib/python3.8/site-packages/pip (python 3.8)
(.venv) $ python3 --version
Python 3.8.10

Conclusion

I am currently completely unable to use Cfn CLI due to an apparent dependency version conflict. Please let me know if i can provide any further info.

greg5123334 commented 2 years ago

Similar to cfn cli fails to install following the provided instructions #864

greg5123334 commented 2 years ago

Workaround

After some tinkering, found the following combination works for me.

pip install --upgrade requests urllib3
pip install markupsafe==2.0.1 pyyaml==5.4.1
pip install werkzeug==2.1.2 --no-deps
mmaeng commented 1 year ago

Adding link to related issue #940