When I run cdk deploy
, I get the following error:
Traceback (most recent call last):
File "app.py", line 3, in <module>
from aws_cdk import core
ModuleNotFoundError: No module named 'aws_cdk'
I installed cdk with npm
npm install -g aws-cdk
I activated the virtual env by
source .env/bin/activate
I'm using python3.8. I installed aws_cdk dependencies by
pip install -r requirements.txt
When editing the python files, I am able to import aws_cdk and run individual functions successfully. I think the problem is that cdk
is located in the /usr
directory:
> which cdk
/usr/local/bin/cdk
And I think it's using python from my /usr/bin
instead of virtual env. How do I make cdk use python in my virtual environment?
EDIT:
requirements.txt
-e .
Python is a fully-supported client language for the AWS CDK and is considered stable. Working with the AWS CDK in Python uses familiar tools, including the standard Python implementation (CPython), virtual environments with virtualenv , and the Python package installer pip .
The cdk deploy subcommand deploys one or more specified stacks to your AWS account. The CDK Toolkit runs your app and synthesizes fresh AWS CloudFormation templates before deploying anything. Therefore, most command line options you can use with cdk synth (for example, --context ) can also be used with cdk deploy .
The cdk synth command from the CDK CLI generates and prints the CloudFormation equivalent of the CDK stack we've defined. The code we write in our CDK applications gets compiled down to CloudFormation before it gets deployed.
In order to delete a CDK stack, we have to use the cdk destroy command. Copied! If we have more than 1 stack in our CDK app, we have to explicitly specify the name of the stack we want to delete.
install via cmd as below.
pip install aws-cdk.core
or
add following line in requirements.txt file
aws-cdk.core
it should resolved
I think you have to order
python -m pip install -r requirements.txt
This will install the standard dependencies for your CDK project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With