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

Created on 26 Oct 2019  路  5Comments  路  Source: aws/aws-cdk

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: Bug Report

bug languagpython p2 packagtools

Most helpful comment

I am having this issue with python 3.9.

All 5 comments

This will be fixed very soon! The fix for this is in aws/jsii#1177

Python 3.8.0 seems to working fine for me now. I had issues earlier, but I cannot reproduce it using the current version.

@henrist thanks for confirming. As @RomainMuller mentioned, the fix was published with jsii 0.21.1 and the cdk >= 1.22.0 should be working.

Please reopen if there are any unresolved issues or questions.

I am having this issue with python 3.9.

@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 :smiley:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abelmokadem picture abelmokadem  路  3Comments

eladb picture eladb  路  3Comments

v-do picture v-do  路  3Comments

schof picture schof  路  3Comments

pepastach picture pepastach  路  3Comments