aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.63k stars 3.91k forks source link

aws_cdk: No module named aws_cdk python venv #31888

Open jagdev-singh-PeopleTech opened 2 days ago

jagdev-singh-PeopleTech commented 2 days ago

Describe the bug

I am working in this POC

https://aws.amazon.com/blogs/machine-learning/enhance-conversational-ai-with-advanced-routing-techniques-with-amazon-bedrock/.

bedrock-agent-implementation

All previous steps are done successfully, but when trying to run cdk bootstrap

I am getting the below error.

import aws_cdk as cdk ModuleNotFoundError: No module named 'aws_cdk' Subprocess exited with error 1

Regression Issue

Last Known Working CDK Version

No response

Expected Behavior

cdk boostrap should not complain about missing module

Current Behavior

import aws_cdk as cdk ModuleNotFoundError: No module named 'aws_cdk' Subprocess exited with error 1

Reproduction Steps

Clone this repo https://github.com/aws-samples/conversational-ai-assistant-multi-route-chain/blob/main/bedrock-agent-implementation/README.md

Ans follow the steps

It will throw error at cdk bootstrap command

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.163.1 (build c14a1ff)

Framework Version

No response

Node.js Version

v20.18.0

OS

Windows 10 Pro

Language

Python

Language Version

Python 3.13.0

Other information

pip list

Package Version


attrs 23.1.0 autopep8 2.0.4 aws-cdk.asset-awscli-v1 2.2.208 aws-cdk.asset-kubectl-v20 2.1.3 aws-cdk.asset-node-proxy-agent-v6 2.1.0 aws-cdk-lib 2.130.0 cattrs 23.1.2 cdk-nag 2.27.209 constructs 10.4.2 importlib-resources 6.1.1 jsii 1.104.0 pip 24.2 publication 0.0.3 pycodestyle 2.11.1 python-dateutil 2.8.2 six 1.16.0 typeguard 2.13.3 typing_extensions 4.8.0

So far I tried the below but didn't helped

  1. Run application on cdk V2 (2.162.1)
  2. Run application on cdk V1 (1.204.0)
  3. uninstall all packages clear pip cache and reinstalled again
  4. Installed aws-cdk separately pip install aws-cdk.core
  5. Removed version from requirements file and tried
ashishdhingra commented 2 days ago

@jagdev-singh-PeopleTech Good morning. Thanks for reporting the issue. Could you please check if you followed instructions at Working with the AWS CDK in Python to initialize your Python venv and pip install all the dependencies?

I was able to run cdk synth locally:

Bundling asset BedrockAgentImplGenAIStack/OpenSearchIndexLambda/Code/Stage...
Unable to find image 'public.ecr.aws/sam/build-python3.11:latest' locally
latest: Pulling from sam/build-python3.11
c2b54dea96a9: Pulling fs layer
f1cbc193d50c: Pulling fs layer
ff55e2a46239: Pulling fs layer
0943ac8b622e: Pulling fs layer
e27e7ad92fb8: Pulling fs layer
9fbd747d59fa: Pulling fs layer
713bb965bbc0: Pulling fs layer
bdf5918d4589: Pulling fs layer
e575f7105700: Pulling fs layer
fe86be7fb63b: Pulling fs layer
ae1c20933700: Pulling fs layer
b8c1a4c39419: Pulling fs layer
374eed4251f8: Pulling fs layer
eecd67b59e2c: Pulling fs layer
e1f6757fd200: Pulling fs layer
bdf5918d4589: Waiting
e575f7105700: Waiting
b8c1a4c39419: Waiting
fe86be7fb63b: Waiting
374eed4251f8: Waiting
ae1c20933700: Waiting
e1f6757fd200: Waiting
e27e7ad92fb8: Waiting
eecd67b59e2c: Waiting
9fbd747d59fa: Waiting
0943ac8b622e: Waiting
ff55e2a46239: Download complete
f1cbc193d50c: Download complete
0943ac8b622e: Verifying Checksum
0943ac8b622e: Download complete
9fbd747d59fa: Verifying Checksum
9fbd747d59fa: Download complete
e27e7ad92fb8: Verifying Checksum
e27e7ad92fb8: Download complete
bdf5918d4589: Verifying Checksum
bdf5918d4589: Download complete
e575f7105700: Verifying Checksum
e575f7105700: Download complete
fe86be7fb63b: Verifying Checksum
fe86be7fb63b: Download complete
ae1c20933700: Download complete
b8c1a4c39419: Download complete
374eed4251f8: Download complete
c2b54dea96a9: Verifying Checksum
c2b54dea96a9: Download complete
eecd67b59e2c: Verifying Checksum
eecd67b59e2c: Download complete
e1f6757fd200: Verifying Checksum
e1f6757fd200: Download complete
c2b54dea96a9: Pull complete
f1cbc193d50c: Pull complete
ff55e2a46239: Pull complete
713bb965bbc0: Verifying Checksum
713bb965bbc0: Download complete
0943ac8b622e: Pull complete
e27e7ad92fb8: Pull complete
9fbd747d59fa: Pull complete
713bb965bbc0: Pull complete
bdf5918d4589: Pull complete
e575f7105700: Pull complete
fe86be7fb63b: Pull complete
ae1c20933700: Pull complete
b8c1a4c39419: Pull complete
374eed4251f8: Pull complete
eecd67b59e2c: Pull complete
e1f6757fd200: Pull complete
Digest: sha256:cad316300cfa88f7be59b11196b37d588fcb78e3b67930ed99ba3bcc8e09c4d4
Status: Downloaded newer image for public.ecr.aws/sam/build-python3.11:latest
WARNING: The directory '/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
Collecting opensearch-py==2.3.2 (from -r requirements.txt (line 1))
  Downloading opensearch_py-2.3.2-py2.py3-none-any.whl.metadata (6.9 kB)
Collecting requests-aws4auth==1.2.3 (from -r requirements.txt (line 2))
  Downloading requests_aws4auth-1.2.3-py2.py3-none-any.whl.metadata (18 kB)
Collecting boto3==1.28.84 (from -r requirements.txt (line 3))
  Downloading boto3-1.28.84-py3-none-any.whl.metadata (6.7 kB)
Collecting urllib3>=1.26.9 (from opensearch-py==2.3.2->-r requirements.txt (line 1))
  Downloading urllib3-2.2.3-py3-none-any.whl.metadata (6.5 kB)
Collecting requests<3.0.0,>=2.4.0 (from opensearch-py==2.3.2->-r requirements.txt (line 1))
  Downloading requests-2.32.3-py3-none-any.whl.metadata (4.6 kB)
Collecting six (from opensearch-py==2.3.2->-r requirements.txt (line 1))
  Downloading six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Collecting python-dateutil (from opensearch-py==2.3.2->-r requirements.txt (line 1))
  Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
Collecting certifi>=2022.12.07 (from opensearch-py==2.3.2->-r requirements.txt (line 1))
  Downloading certifi-2024.8.30-py3-none-any.whl.metadata (2.2 kB)
Collecting botocore<1.32.0,>=1.31.84 (from boto3==1.28.84->-r requirements.txt (line 3))
  Downloading botocore-1.31.85-py3-none-any.whl.metadata (6.1 kB)
Collecting jmespath<2.0.0,>=0.7.1 (from boto3==1.28.84->-r requirements.txt (line 3))
  Downloading jmespath-1.0.1-py3-none-any.whl.metadata (7.6 kB)
Collecting s3transfer<0.8.0,>=0.7.0 (from boto3==1.28.84->-r requirements.txt (line 3))
  Downloading s3transfer-0.7.0-py3-none-any.whl.metadata (1.8 kB)
Collecting urllib3>=1.26.9 (from opensearch-py==2.3.2->-r requirements.txt (line 1))
  Downloading urllib3-2.0.7-py3-none-any.whl.metadata (6.6 kB)
Collecting charset-normalizer<4,>=2 (from requests<3.0.0,>=2.4.0->opensearch-py==2.3.2->-r requirements.txt (line 1))
  Downloading charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata (34 kB)
Collecting idna<4,>=2.5 (from requests<3.0.0,>=2.4.0->opensearch-py==2.3.2->-r requirements.txt (line 1))
  Downloading idna-3.10-py3-none-any.whl.metadata (10 kB)
Downloading opensearch_py-2.3.2-py2.py3-none-any.whl (327 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 327.3/327.3 kB 9.9 MB/s eta 0:00:00
Downloading requests_aws4auth-1.2.3-py2.py3-none-any.whl (24 kB)
Downloading boto3-1.28.84-py3-none-any.whl (135 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 135.8/135.8 kB 54.7 MB/s eta 0:00:00
Downloading botocore-1.31.85-py3-none-any.whl (11.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.3/11.3 MB 59.7 MB/s eta 0:00:00
Downloading certifi-2024.8.30-py3-none-any.whl (167 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 167.3/167.3 kB 96.4 MB/s eta 0:00:00
Downloading jmespath-1.0.1-py3-none-any.whl (20 kB)
Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 229.9/229.9 kB 216.9 MB/s eta 0:00:00
Downloading requests-2.32.3-py3-none-any.whl (64 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 64.9/64.9 kB 23.5 MB/s eta 0:00:00
Downloading s3transfer-0.7.0-py3-none-any.whl (79 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.8/79.8 kB 355.2 MB/s eta 0:00:00
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Downloading urllib3-2.0.7-py3-none-any.whl (124 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 124.2/124.2 kB 292.0 MB/s eta 0:00:00
Downloading charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (138 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 138.2/138.2 kB 66.7 MB/s eta 0:00:00
Downloading idna-3.10-py3-none-any.whl (70 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 70.4/70.4 kB 125.0 MB/s eta 0:00:00
Installing collected packages: urllib3, six, jmespath, idna, charset-normalizer, certifi, requests, python-dateutil, requests-aws4auth, opensearch-py, botocore, s3transfer, boto3
Successfully installed boto3-1.28.84 botocore-1.31.85 certifi-2024.8.30 charset-normalizer-3.4.0 idna-3.10 jmespath-1.0.1 opensearch-py-2.3.2 python-dateutil-2.9.0.post0 requests-2.32.3 requests-aws4auth-1.2.3 s3transfer-0.7.0 six-1.16.0 urllib3-2.0.7

[notice] A new release of pip is available: 24.0 -> 24.2
[notice] To update, run: pip install --upgrade pip
Successfully synthesized to /Users/<<username>>/source/GitHub/aws-samples/conversational-ai-assistant-multi-route-chain/bedrock-agent-implementation/cdk.out
Supply a stack id (BedrockAgentImplBaseInfraStack, BedrockAgentImplGenAIStack, BedrockAgentImplFrontendStack) to display its template.

Did your pip install -r ../requirements.txt installed the modules properly?

Collecting attrs==23.1.0 (from -r ../requirements.txt (line 1))
  Downloading attrs-23.1.0-py3-none-any.whl.metadata (11 kB)
Collecting autopep8==2.0.4 (from -r ../requirements.txt (line 2))
  Downloading autopep8-2.0.4-py2.py3-none-any.whl.metadata (17 kB)
Collecting aws-cdk-lib==2.130.0 (from -r ../requirements.txt (line 3))
  Downloading aws_cdk_lib-2.130.0-py3-none-any.whl.metadata (59 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 59.3/59.3 kB 1.9 MB/s eta 0:00:00
Collecting constructs<11.0.0,>=10.0.0 (from -r ../requirements.txt (line 4))
  Downloading constructs-10.4.2-py3-none-any.whl.metadata (2.9 kB)
Collecting cattrs==23.1.2 (from -r ../requirements.txt (line 5))
  Downloading cattrs-23.1.2-py3-none-any.whl.metadata (9.3 kB)
Collecting cdk-nag==2.27.209 (from -r ../requirements.txt (line 6))
  Downloading cdk_nag-2.27.209-py3-none-any.whl.metadata (21 kB)
Collecting importlib-resources==6.1.1 (from -r ../requirements.txt (line 7))
  Downloading importlib_resources-6.1.1-py3-none-any.whl.metadata (4.1 kB)
Collecting publication==0.0.3 (from -r ../requirements.txt (line 8))
  Downloading publication-0.0.3-py2.py3-none-any.whl.metadata (8.7 kB)
Collecting pycodestyle==2.11.1 (from -r ../requirements.txt (line 9))
  Downloading pycodestyle-2.11.1-py2.py3-none-any.whl.metadata (4.5 kB)
Collecting python-dateutil==2.8.2 (from -r ../requirements.txt (line 10))
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl.metadata (8.2 kB)
Collecting six==1.16.0 (from -r ../requirements.txt (line 11))
  Downloading six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Collecting typeguard==2.13.3 (from -r ../requirements.txt (line 12))
  Downloading typeguard-2.13.3-py3-none-any.whl.metadata (3.6 kB)
Collecting typing_extensions==4.8.0 (from -r ../requirements.txt (line 13))
  Downloading typing_extensions-4.8.0-py3-none-any.whl.metadata (3.0 kB)
Collecting aws-cdk.asset-awscli-v1<3.0.0,>=2.2.202 (from aws-cdk-lib==2.130.0->-r ../requirements.txt (line 3))
  Downloading aws_cdk.asset_awscli_v1-2.2.208-py3-none-any.whl.metadata (1.1 kB)
Collecting aws-cdk.asset-kubectl-v20<3.0.0,>=2.1.2 (from aws-cdk-lib==2.130.0->-r ../requirements.txt (line 3))
  Downloading aws_cdk.asset_kubectl_v20-2.1.3-py3-none-any.whl.metadata (1.1 kB)
Collecting aws-cdk.asset-node-proxy-agent-v6<3.0.0,>=2.0.1 (from aws-cdk-lib==2.130.0->-r ../requirements.txt (line 3))
  Using cached aws_cdk.asset_node_proxy_agent_v6-2.1.0-py3-none-any.whl.metadata (1.1 kB)
Collecting jsii<2.0.0,>=1.94.0 (from aws-cdk-lib==2.130.0->-r ../requirements.txt (line 3))
  Downloading jsii-1.104.0-py3-none-any.whl.metadata (79 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.7/79.7 kB 5.4 MB/s eta 0:00:00
Downloading attrs-23.1.0-py3-none-any.whl (61 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.2/61.2 kB 6.4 MB/s eta 0:00:00
Downloading autopep8-2.0.4-py2.py3-none-any.whl (45 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.3/45.3 kB 5.0 MB/s eta 0:00:00
Downloading aws_cdk_lib-2.130.0-py3-none-any.whl (34.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 34.3/34.3 MB 47.6 MB/s eta 0:00:00
Downloading cattrs-23.1.2-py3-none-any.whl (50 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 50.8/50.8 kB 3.0 MB/s eta 0:00:00
Downloading cdk_nag-2.27.209-py3-none-any.whl (714 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 714.5/714.5 kB 38.8 MB/s eta 0:00:00
Downloading importlib_resources-6.1.1-py3-none-any.whl (33 kB)
Downloading publication-0.0.3-py2.py3-none-any.whl (7.7 kB)
Downloading pycodestyle-2.11.1-py2.py3-none-any.whl (31 kB)
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 kB 23.7 MB/s eta 0:00:00
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Downloading typeguard-2.13.3-py3-none-any.whl (17 kB)
Downloading typing_extensions-4.8.0-py3-none-any.whl (31 kB)
Downloading constructs-10.4.2-py3-none-any.whl (63 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 63.5/63.5 kB 6.0 MB/s eta 0:00:00
Downloading aws_cdk.asset_awscli_v1-2.2.208-py3-none-any.whl (17.1 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17.1/17.1 MB 58.3 MB/s eta 0:00:00
Downloading aws_cdk.asset_kubectl_v20-2.1.3-py3-none-any.whl (25.5 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 25.5/25.5 MB 50.5 MB/s eta 0:00:00
Using cached aws_cdk.asset_node_proxy_agent_v6-2.1.0-py3-none-any.whl (1.5 MB)
Downloading jsii-1.104.0-py3-none-any.whl (554 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 554.8/554.8 kB 32.0 MB/s eta 0:00:00
Installing collected packages: publication, typing_extensions, typeguard, six, pycodestyle, importlib-resources, attrs, python-dateutil, cattrs, autopep8, jsii, constructs, aws-cdk.asset-node-proxy-agent-v6, aws-cdk.asset-kubectl-v20, aws-cdk.asset-awscli-v1, aws-cdk-lib, cdk-nag
Successfully installed attrs-23.1.0 autopep8-2.0.4 aws-cdk-lib-2.130.0 aws-cdk.asset-awscli-v1-2.2.208 aws-cdk.asset-kubectl-v20-2.1.3 aws-cdk.asset-node-proxy-agent-v6-2.1.0 cattrs-23.1.2 cdk-nag-2.27.209 constructs-10.4.2 importlib-resources-6.1.1 jsii-1.104.0 publication-0.0.3 pycodestyle-2.11.1 python-dateutil-2.8.2 six-1.16.0 typeguard-2.13.3 typing_extensions-4.8.0

[notice] A new release of pip is available: 24.0 -> 24.2
[notice] To update, run: pip install --upgrade pip

Thanks, Ashish

github-actions[bot] commented 4 hours ago

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.