Skip to content

(init-templates): python README only documents cmd activation, not PowerShell #1984

Description

@martinchaumeron

Describe the bug

The Python init template README documents virtualenv activation on Windows as:

% .venv\Scripts\activate.bat

Running a .bat file from PowerShell spawns a separate cmd process, so the
environment changes do not persist in the calling shell. The virtualenv silently
stays inactive — no error is shown.

PowerShell is the default shell on Windows 11 and in the VS Code integrated
terminal, so this affects most Windows users following the template instructions.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

The README documents the PowerShell activation command alongside the cmd one.

Current Behavior

Only activate.bat is documented. Users get no error at activation time, then
hit confusing failures later — for example Subprocess exited with error 9009
on cdk synth or cdk deploy, because python is not resolved from the venv.

Reproduction Steps

  1. On Windows, in PowerShell: cdk init app --language python
  2. Run .venv\Scripts\activate.bat as documented in the generated README
  3. Run python -c "import sys; print(sys.prefix)" — it points to the system
    Python, not to the project venv

Possible Solution

Replace the Windows section of the template README with:

# PowerShell
.\.venv\Scripts\Activate.ps1

# cmd.exe
.venv\Scripts\activate.bat

A note that Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
may be required before Activate.ps1 can run would also help, since it is the
default blocker on a standard Windows setup.

Related: aws/aws-cdk#20156 — another Windows/PowerShell friction point with the
same template.

I'm happy to open a PR for this.

Additional Information/Context

No response

CDK CLI Version

2.1142.0

Framework Version

No response

Node.js Version

v24.21.0

OS

Windows 11

Language

Python

Language Version

No response

Other information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions