question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

aws-cdk is incompatible with python 3.8.0 because of a bug in jsii

See original GitHub issue

In python 3.8.0, when you attempt to run any cdk cli functions, you end up with the following import error:

Traceback (most recent call last):
  File "app.py", line 3, in <module>
    from aws_cdk import core
  File "/Users/***/.local/share/virtualenvs/***/lib/python3.8/site-packages/aws_cdk/core/__init__.py", line 6, in <module>
    import jsii
  File "/Users/***/.local/share/virtualenvs/***/lib/python3.8/site-packages/jsii/__init__.py", line 4, in <module>
    from ._runtime import (
  File "/Users/***/.local/share/virtualenvs/***/lib/python3.8/site-packages/jsii/_runtime.py", line 6, in <module>
    from jsii import _reference_map
  File "/Users/***/.local/share/virtualenvs/***/lib/python3.8/site-packages/jsii/_reference_map.py", line 6, in <module>
    from ._kernel.types import JSClass, Referenceable
  File "/Users/***/.local/share/virtualenvs/***/lib/python3.8/site-packages/jsii/_kernel/__init__.py", line 15, in <module>
    from jsii._kernel.providers import BaseProvider, ProcessProvider
  File "/Users/***/.local/share/virtualenvs/***/lib/python3.8/site-packages/jsii/_kernel/providers/__init__.py", line 2, in <module>
    from jsii._kernel.providers.process import ProcessProvider
  File "/Users/***/.local/share/virtualenvs/***/lib/python3.8/site-packages/jsii/_kernel/providers/process.py", line 15, in <module>
    import cattr  # type: ignore
  File "/Users/***/.local/share/virtualenvs/***/lib/python3.8/site-packages/cattr/__init__.py", line 2, in <module>
    from .converters import Converter, UnstructureStrategy
  File "/Users/***/.local/share/virtualenvs/***/lib/python3.8/site-packages/cattr/converters.py", line 15, in <module>
    from ._compat import (
  File "/Users/***/.local/share/virtualenvs/***/lib/python3.8/site-packages/cattr/_compat.py", line 86, in <module>
    from typing import _Union
ImportError: cannot import name '_Union' from 'typing' (/Users/***/.pyenv/versions/3.8.0/lib/python3.8/typing.py)
Subprocess exited with error 1

This does not happen in python 3.7.4. I have opened a bug report in the jsii module: https://github.com/aws/jsii/issues/913.

Reproduction Steps

Given python 3.8.0 is installed:

cdk ls

Error Log

Environment

  • CLI Version : aws-cli/1.16.260 Python/3.7.4 Darwin/19.0.0 botocore/1.12.250
  • Framework Version: 1.14.0 (build 261a1bf)
  • OS : MacOS 10.15.1 beta
  • Language : Python 3.8.0

Other

Initial fix should be to only allow python 3.7 until the jsii bug is fixed.


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
vennempcommented, Oct 14, 2020

I am having this issue with python 3.9.

0reactions
burningalchemistcommented, Oct 17, 2020

@vennemp It’s the same thing because of cattr dependency, which doesn’t support Python 3.9 yet (but it’s almost here) - https://github.com/Tinche/cattrs/issues/100 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting common AWS CDK issues
When synthesizing an AWS CDK stack, I receive an error because the AWS ... and different versions of the library modules may have...
Read more >
JSII error while migrating from AWS CDK v1 to v2
We are currently migrating from aws cdk v1 to v2. While following the steps from the documentation, I tried to do cdk ls...
Read more >
jsii | Yarn - Package Manager
Bug Fixes · allow Missing Dotnet Version Suffix (#1047 (fc366d0), closes #1037 · dotnet/roslyn: analyzer target framework (#1071 (fea0f0a), closes aws/aws-cdk# ...
Read more >
Changelog - AWS Lambda Powertools for Python
Bug Fixes¶ · lock dependencies · mypy errors · lint files · ci: temporarly remove pypi test deployment · ci: use docker driver...
Read more >
@aws-cdk/core: Versions | Openbase
5 months ago. Bug Fixes. Revert to jsii-pacmak@1.62.0 as dynamic runtime type-checking it introduced for Python results in incorrect code being produced.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found