2
votes

My stack:

  • python 3.6
  • Node.js 11.3.0
  • jsii-0.20.11 (automatically installed when aws cdk is installed via npm)

I just tried cdk init and then did pip install -e.

After that, I did cdk deploy and it gives me the following error:

Traceback (most recent call last):
  File "app.py", line 3, in <module>
    from aws_cdk import core
  File "C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\aws_cdk\core\__init__.py", line 1967, in <module>
    class DependableTrait(metaclass=jsii.JSIIAbstractClass, jsii_type="@aws-cdk/core.DependableTrait"):
TypeError: __new__() got an unexpected keyword argument 'jsii_type'
Subprocess exited with error 1

(.env) C:\Users\sgoud12\myfolder\myprojects\myapp\cdk>
(.env) C:\Users\sgoud12\myfolder\myprojects\myapp\cdk>fs.js:122
    throw err;
    ^

Error: EOF: end of file, read
    at Object.readSync (fs.js:517:3)
    at SyncStdio.readLine (C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13350:25)
    at InputOutput.read (C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:13300:34)
    at KernelHost.run (C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:7231:32)
    at Immediate.setImmediate (C:\Users\sgoud12\myfolder\myprojects\myapp\cdk\.env\lib\site-packages\jsii\_embedded\jsii\jsii-runtime.js:7239:37)
    at processImmediate (timers.js:632:19)
2

2 Answers

0
votes

It usually means some kind of versions missmarch: aws-cdk in npm and aws-cdk in python. Given that it's a pretty old question I suppose updating all packages or even reinstall the environment should help.

There are mentions of a similar problem in the official aws-cdk bug tracker:

https://github.com/aws/aws-cdk/issues/3349

https://github.com/aws/aws-cdk/issues/3293

0
votes

I agree, this is frustrating and hard to find a fix for. Using the links from @Trilliput

My Steps:

  1. Uninstall pip
  2. Update homebrew
  3. Remove the aws cli
  4. Reinstall the aws cli
  5. uninstall aws cdk
  6. reinstall aws cdk

Commands:

sudo pip uninstall pip
brew update
sudo rm /usr/local/bin/aws
sudo rm /usr/local/bin/aws_completer
sudo rm -rf /usr/local/aws-cli
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
pip3 uninstall aws-cdk.cdk
pip3 install aws-cdk.cdk --use-feature=2020-resolver

That didn't work as I hoped, so I used all of these commands below. I called it to scorched earth reinstall:

sudo pip uninstall pip
brew update
sudo rm /usr/local/bin/aws
sudo rm /usr/local/bin/aws_completer
sudo rm -rf /usr/local/aws-cli
brew uninstall node
brew uninstall pyenv

# CLOSE your terminal window and open a NEW terminal window.  
# when you run [which python] you should get /usr/bin/python
# run these commands to remove node and npm

https://gist.github.com/TonyMtz/d75101d9bdf764c890ef

curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
python3 get-pip.py

brew install python3

# old CDK
pip3 uninstall aws-cdk.cdk

#new CDK
pip3 uninstall aws-cdk.core

# NEW CDK
pip3 install aws-cdk.core

#pip3 install aws-cdk.core --use-feature=2020-resolver

# reinstall aws cdk
npm install -g aws-cdk
npm install -g [email protected]
sudo npm install -g [email protected]
npm install -g aws-cdk
sudo npm install -g aws-cdk
sudo -i
sudo npm install -g aws-cdk
cdk --version