{"id":36014,"date":"2026-11-27T22:05:29","date_gmt":"2026-11-27T22:05:29","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=36014"},"modified":"2026-11-27T22:05:29","modified_gmt":"2026-11-27T22:05:29","slug":"how-to-install-kapitan-in-windows","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-install-kapitan-in-windows\/","title":{"rendered":"How to install Kapitan in Windows using wsl?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Kapitan is a Python-based configuration management tool, and on Windows it runs best inside the Windows Subsystem for Linux (WSL). This guide fills in the commands the steps above leave out: installing WSL and Ubuntu, installing Kapitan cleanly with pipx or a virtual environment on current Ubuntu releases, checking it with a small compile test, and fixing the errors people hit most often.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1 &#8211; Install WSL<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2 &#8211; Install Ubuntu WSL image from Microsoft Store<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3 &#8211; Login to ubuntu wsl and install Kapitan<\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">$ sudo apt-<span class=\"hljs-keyword\">get<\/span> update &amp;&amp; sudo apt-<span class=\"hljs-keyword\">get<\/span> install -y python3.8-dev python3-pip python3-yaml\n$ pip3 install --user --upgrade kapitan\n$ sudo pip3 install --upgrade kapitan\n$ kapitan --version<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Windows 11, or Windows 10 version 2004 (build 19041) or later, so the single <code>wsl --install<\/code> command is available.<\/li>\n\n\n<li>Virtualization turned on in the BIOS\/UEFI. WSL 2 needs it.<\/li>\n\n\n<li>An administrator PowerShell or Windows Terminal session for the WSL install.<\/li>\n\n\n<li>Internet access from inside WSL to reach the Ubuntu package mirrors and PyPI.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Kapitan pulls in dependencies such as Jinja2, Jsonnet bindings and Kadet, so it needs a working Python 3 toolchain. The steps below use whatever Python 3 ships with your Ubuntu release and do not pin a specific minor version.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps 1 and 2: install WSL and Ubuntu<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You don&#039;t need to visit the Microsoft Store as a separate step. A single command enables the WSL features, installs the WSL 2 kernel and adds Ubuntu as the default distribution. Run it in an <strong>administrator<\/strong> PowerShell:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Install WSL with the default Ubuntu distribution<\/span>\nwsl --install\n\n<span class=\"hljs-comment\"># Or list the available distributions and pick a specific one<\/span>\nwsl --<span class=\"hljs-keyword\">list<\/span> --online\nwsl --install -d Ubuntu<span class=\"hljs-number\">-24.04<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Restart Windows when prompted. On first launch, Ubuntu asks you to create a Linux username and password. This account is separate from your Windows login, and <code>sudo<\/code> will ask for this password. Then confirm the distribution is running under WSL 2:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">wsl --<span class=\"hljs-keyword\">list<\/span> --verbose\n\n<span class=\"hljs-comment\"># Expected output (similar to)<\/span>\n<span class=\"hljs-comment\">#   NAME            STATE           VERSION<\/span>\n<span class=\"hljs-comment\"># * Ubuntu-24.04    Running         2<\/span>\n\n<span class=\"hljs-comment\"># If VERSION shows 1, convert it<\/span>\nwsl --set-version Ubuntu<span class=\"hljs-number\">-24.04<\/span> <span class=\"hljs-number\">2<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> For more PowerShell basics, see the <a href=\"https:\/\/www.devopsschool.com\/blog\/powershell-tutorials-command-line-reference\/\">PowerShell command line reference<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3 corrected: install Kapitan inside Ubuntu<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The command block above will fail on current Ubuntu images. The fixed approach installs the generic Python packages, then installs Kapitan into its own isolated environment so it never touches the system Python. Open the Ubuntu terminal and use <strong>one<\/strong> of the options below.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Option A: pipx (recommended for a command-line tool).<\/strong> pipx creates a private virtual environment for Kapitan and puts the <code>kapitan<\/code> command on your PATH.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">sudo apt update\nsudo apt install -y python3 python3-dev python3-venv pipx build-essential git\n\npipx ensurepath          <span class=\"hljs-comment\"># adds ~\/.local\/bin to PATH<\/span>\nexec $SHELL -l           <span class=\"hljs-comment\"># reload the shell so the PATH change applies<\/span>\n\npipx install kapitan\nkapitan --version<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Option B: a virtual environment.<\/strong> Use this if you want to pin Kapitan per project or install extra Python libraries next to it.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">sudo apt update\nsudo apt install -y python3 python3-dev python3-venv python3-pip build-essential git\n\npython3 -m venv ~<span class=\"hljs-regexp\">\/.venvs\/<\/span>kapitan\nsource ~<span class=\"hljs-regexp\">\/.venvs\/<\/span>kapitan\/bin\/activate\n\npip install --upgrade pip\npip install kapitan\nkapitan --version<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><code>python3-dev<\/code> and <code>build-essential<\/code> provide the headers and compiler that pip needs if a dependency has no prebuilt wheel for your Python version. <code>kapitan --version<\/code> should print a version number. With Option B, run <code>source ~\/.venvs\/kapitan\/bin\/activate<\/code> in each new terminal before you use <code>kapitan<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Alternative: run Kapitan from the Docker image<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you already use Docker Desktop with WSL integration turned on for your Ubuntu distribution, you can skip the Python setup and use the official <code>kapicorp\/kapitan<\/code> image. Run it from the root of your Kapitan repository:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">docker run -t --rm -u $(id -u) -v $(pwd):\/src:delegated kapicorp\/kapitan --version\n\n<span class=\"hljs-comment\"># Optional alias so it behaves like a local install<\/span>\nalias kapitan=<span class=\"hljs-string\">'docker run -t --rm -u $(id -u) -v $(pwd):\/src:delegated kapicorp\/kapitan'<\/span>\nkapitan compile<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><code>-u $(id -u)<\/code> makes compiled files belong to your WSL user instead of root, and <code>-v $(pwd):\/src<\/code> mounts the current directory where the container expects the project.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verify the install with a first compile<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A version number shows the binary runs. A small compile shows that the inventory and templating also work. Create the project in your Linux home directory, not under <code>\/mnt\/c<\/code>, because file access across the Windows boundary is much slower.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">mkdir -p ~\/kapitan-demo\/inventory\/targets ~\/kapitan-demo\/templates\ncd ~\/kapitan-demo\n\ncat &gt; inventory\/targets\/dev.yml &lt;&lt;<span class=\"hljs-string\">'EOF'<\/span>\nparameters:\n  greeting: Hello from Kapitan on WSL\n  kapitan:\n    vars:\n      target: dev\n    compile:\n      - output_path: .\n        input_type: jinja2\n        input_paths:\n          - templates\/hello.txt\nEOF\n\ncat &gt; templates\/hello.txt &lt;&lt;<span class=\"hljs-string\">'EOF'<\/span>\n{{ inventory.parameters.greeting }} (target: {{ inventory.parameters.kapitan.vars.target }})\nEOF\n\nkapitan compile\ncat compiled\/dev\/hello.txt<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Kapitan reads every file in <code>inventory\/targets\/<\/code> as a target, renders the Jinja2 template with the inventory available as <code>inventory<\/code>, and writes the result to <code>compiled\/&lt;target&gt;\/<\/code>. The last command should print <code>Hello from Kapitan on WSL (target: dev)<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common errors and fixes<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Error<\/th><th>Cause<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td><code>E: Unable to locate package python3.8-dev<\/code><\/td><td>Ubuntu 22.04 and 24.04 do not ship Python 3.8 in their default repositories.<\/td><td>Install <code>python3-dev<\/code>, which matches the system Python.<\/td><\/tr><tr><td><code>error: externally-managed-environment<\/code><\/td><td>Ubuntu 23.04 and later block <code>pip install<\/code> into the system Python (PEP 668).<\/td><td>Use pipx or a virtual environment. Don&#039;t use <code>--break-system-packages<\/code>.<\/td><\/tr><tr><td><code>kapitan: command not found<\/code><\/td><td><code>~\/.local\/bin<\/code> is not on PATH, or the venv is not activated.<\/td><td>Run <code>pipx ensurepath<\/code> and reopen the shell, or <code>source ~\/.venvs\/kapitan\/bin\/activate<\/code>.<\/td><\/tr><tr><td>Build fails with <code>gcc<\/code> or <code>Python.h<\/code> errors<\/td><td>A dependency is compiling from source without build tools.<\/td><td>Install <code>build-essential<\/code> and <code>python3-dev<\/code>, then retry.<\/td><\/tr><tr><td><code>No matching distribution found for kapitan<\/code><\/td><td>Your Python version is outside the range the current Kapitan release supports.<\/td><td>Check the Requires-Python value on Kapitan&#039;s PyPI page, then use a matching Python or the Docker image.<\/td><\/tr><tr><td><code>wsl --install<\/code> only prints help text<\/td><td>WSL is already partly installed on the machine.<\/td><td>Run <code>wsl --install -d Ubuntu<\/code> to add the distribution directly.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Upgrading, uninstalling and good practice<\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># pipx install<\/span>\npipx upgrade kapitan\npipx uninstall kapitan\n\n<span class=\"hljs-comment\"># venv install<\/span>\nsource ~\/.venvs\/kapitan\/bin\/activate\npip install --upgrade kapitan\ndeactivate &amp;&amp; rm -rf ~\/.venvs\/kapitan<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li>Never run <code>sudo pip install<\/code>. It can overwrite Python packages that <code>apt<\/code> and Ubuntu tools rely on.<\/li>\n\n\n<li>Pin the Kapitan version per repository (for example <code>pip install kapitan==&lt;version&gt;<\/code> in a venv, or a fixed Docker image tag) so the whole team and CI compile the same output.<\/li>\n\n\n<li>Keep Kapitan repositories inside the WSL filesystem and open them from Windows editors through the <code>\\\\wsl$<\/code> path or VS Code&#039;s WSL extension.<\/li>\n\n\n<li>Kapitan can manage secrets through references backed by GPG, Vault or cloud KMS. Commit only the reference files, never plaintext secrets.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Can Kapitan run natively on Windows without WSL?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Kapitan is developed and tested mainly on Linux and macOS, and some of its dependencies are difficult to build on native Windows. WSL or the Docker image is the reliable way to run it on a Windows machine.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Which Ubuntu version should I use in WSL for Kapitan?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A current LTS release such as Ubuntu 22.04 or 24.04 works. If the system Python is outside the range a Kapitan release supports, use the Docker image or install a matching Python version.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why does pip install kapitan fail with externally-managed-environment?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Newer Ubuntu releases mark the system Python as managed by apt and refuse global pip installs. Install Kapitan with pipx or inside a virtual environment instead.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I check that Kapitan is installed correctly?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run <code>kapitan --version<\/code> to confirm the command works. Then run <code>kapitan compile<\/code> on a small test inventory and check that output files appear under <code>compiled\/&lt;target&gt;\/<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Should I install Kapitan with both pip &#8211;user and sudo pip?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. The original commands install it twice, and <code>sudo pip<\/code> changes the system Python. A single pipx or virtual environment install is enough.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related tutorials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/powershell-tutorials-command-line-reference\/\">Powershell Tutorials: Command Line reference<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/how-to-install-and-configure-pre-commit-on-macos-windows-and-linux-complete-step-by-step-guide\/\">How to Install and Configure pre-commit on macOS, Windows, and Linux: Complete Step-by-Step Guide<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/operating-systems\/linux\/\">More Linux tutorials<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/operating-systems\/windows\/\">More Windows tutorials<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Kapitan is a Python-based configuration management tool, and on Windows it runs best inside the Windows Subsystem for Linux (WSL). This guide fills in the commands the&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[55,4957],"tags":[702],"class_list":["post-36014","post","type-post","status-publish","format-standard","hentry","category-windows","category-linux","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/36014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=36014"}],"version-history":[{"count":4,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/36014\/revisions"}],"predecessor-version":[{"id":80372,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/36014\/revisions\/80372"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=36014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=36014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=36014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}