[Python] ModuleNotFoundError: No module named aws_cdk

Discussão em 'Python' iniciado por Stack, Maio 27, 2025.

  1. Stack

    Stack Membro Participativo

    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 .

    Continue reading...

Compartilhe esta Página