chocolatey/choco · error · FileNotFoundException

Unable to find pip

Error message

Unable to find pip

What it means

While resolving the pip executable path, PythonService searches the Scripts folder next to python.exe (pipPath = combine(dirName(topLevelPath), 'Scripts', 'pip.exe')). If pip.exe is not found and _exePath stays blank, EnsureExecutablePathSet throws FileNotFoundException.

Source

Thrown at src/chocolatey/infrastructure.app/services/PythonService.cs:271

            {
                var binRoot = Environment.GetEnvironmentVariable(EnvironmentVariables.System.ChocolateyBinRoot);
                if (string.IsNullOrWhiteSpace(binRoot))
                {
                    binRoot = "c:\\tools";
                }

                topLevelPath = _fileSystem.CombinePaths(binRoot, "python");
            }

            pipPath = _fileSystem.CombinePaths(_fileSystem.GetDirectoryName(topLevelPath), "Scripts", "pip.exe");
            if (_fileSystem.FileExists(pipPath))
            {
                _exePath = pipPath;
            }

            if (string.IsNullOrWhiteSpace(_exePath))
            {
                throw new FileNotFoundException("Unable to find pip");
            }
        }

        private string BuildArguments(ChocolateyConfiguration config, IDictionary<string, ExternalCommandArgument> argsDictionary)
        {
            var args = ExternalCommandArgsBuilder.BuildArguments(config, argsDictionary);

            args = args.Replace(LogLevelToken, config.Debug ? "-vvv" : "");

            if (config.CommandName.IsEqualTo("install"))
            {
                args = args.Replace(ForceToken, config.Force ? "--ignore-installed" : "");
            }
            else if (config.CommandName.IsEqualTo("upgrade"))
            {
                args = args.Replace(ForceToken, config.Force ? "--force-reinstall" : "");
            }
            else

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. Install pip for the detected Python (python -m ensurepip, or bootstrap via get-pip.py)
  2. Ensure pip.exe lives in the Scripts folder next to python.exe
  3. Reinstall Python with the pip component selected
  4. Use a virtualenv that includes pip and point Python at it

Example fix

// before
# pip missing -> error
// after
python -m ensurepip --upgrade
choco install requests --source=python
Defensive patterns

Strategy: validation

Validate before calling

// Verify pip.exe exists in the expected Scripts folder before using the python source.
var scriptsDir = Path.Combine(Path.GetDirectoryName(pythonExe), "Scripts");
if (!File.Exists(Path.Combine(scriptsDir, "pip.exe"))) {
    Console.Error.WriteLine("pip not found; run: python -m ensurepip --upgrade");
    return;
}

Try / catch

try { pythonService.Install(config); }
catch (FileNotFoundException ex) when (ex.Message == "Unable to find pip") {
    // bootstrap pip then retry
    Process.Start("python", "-m ensurepip --upgrade").WaitForExit();
    pythonService.Install(config);
}

Prevention

When it happens

Trigger: Python is detected but pip.exe is absent from the expected <python dir>\Scripts\pip.exe location, so after FileExists checks _exePath is still null/whitespace.

Common situations: Python installed without pip; pip installed elsewhere; custom/embeddable Python layout without Scripts; Python 2.7.x without pip bundled.

Related errors


AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13). Data as JSON: /api/errors/ded950d1f9224682. Report an issue: GitHub.