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.

core: unable to import Stack

See original GitHub issue

What is the problem?

I have a similar problem to issue #17950 with Python. When migrating to cdk 2.0.0/2.1.0

Tried with:

from aws_cdk import Stack

class MyStack(Stack):

Got ImportError: cannot import name 'Stack' from 'aws_cdk' (unknown location)

Also tried with:

import aws_cdk as core

class MyStack(core.Stack):

Got AttributeError: module 'aws_cdk' has no attribute 'Stack'

(using python 3.8.9, cdk 2.1.0)

Reproduction Steps

Add aws-cdk-lib==2.1.0 in requirements.txt

Try to import Stack from core

What did you expect to happen?

The import should work…

What actually happened?

2 different errors with 2 different ways to import the class.

CDK CLI Version

2.1.0

Framework Version

No response

Node.js Version

17.0.1

OS

macOs BigSur M1

Language

Python

Language Version

Python 3.8.9

Other information

No response

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
rob-saffellcommented, Feb 1, 2022

I recreated this issue. It appears that the problem is that you are using aws-cdk.core (or a similar old version) and have not installed aws-cdk-lib. Removing aws-cdk.core with python3 -m pip uninstall aws-cdk.core And then installing the new major release with python -m pip install aws-cdk-lib should resolve your issue.

0reactions
github-actions[bot]commented, Dec 25, 2021

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS-CDK cannot import core - python
AWS-CDK cannot import core · 1. Does your current directory contain a file called aws_cdk.py ? – jordanm · 6. Sometimes it's the...
Read more >
Importing a stack into AWS CloudFormation StackSets
The AWS CloudFormation stack import operation can import existing stacks into new or existing stack sets, so that you can migrate existing stacks...
Read more >
How to export and import stack output values in CDK?
To share information between CDK stacks using the low-level CloudFormation features, we need to do following: 1. Import `core` module. The ...
Read more >
pulumi stack import
A deployment that was exported from a stack using pulumi stack export and hand-edited to correct inconsistencies due to failed updates, manual changes...
Read more >
CDK tips, part 3 – how to unblock cross-stack references
import * as cdk from '@aws-cdk/core'; import * as lambda from ... the effect is the same – the producing Stack fails to...
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