checkov-vscode icon indicating copy to clipboard operation
checkov-vscode copied to clipboard

Windows Installation Failure using pip

Open mitchellresnick opened this issue 3 years ago • 2 comments

Description On Windows, when Docker is not installed and pip is desired to install, the user sees an error stating the command python3 does not exist.

This is due to the fact that when installed on Windows, Python is registered as python instead of python3.

During the first-time setup of Checkov in Visual Studio Code, the following error is observed: [error]: Failed to install or update Checkov using pip3. Error: {"error":{"killed":false,"code":9009,"signal":null,"cmd":"python3 --version","message":"Command failed: python3 --version\nPython was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.\r\n","stack":"Error: Command failed: python3 --version\nPython was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.\r\n\n\tat ChildProcess.exithandler (child_process.js:317:12)\n\tat ChildProcess.emit (events.js:315:20)\n\tat maybeClose (internal/child_process.js:1048:16)\n\tat Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)"}}

To fix this error, an additional check should be run to see if python --version returns a valid response.

Reproduction of Issue

  1. Ensure that Docker is not installed on the system.
  2. Install Python on Windows for all users and select the option to add Python to the PATH.
  3. Install the Checkov extension within Visual Studio Code
  4. Observe that when running the command python3 --version an error is thrown stating python3 is not recognized. Additionally, run python --version to see that the version is returned as expected.
  5. Open a supported file in VS Code and using the command palette execute the "Checkov Scan" command.
  6. After a few seconds, open Checkov logs using the command palette and observe the error stating that the command python3 does not exist.

Proposed solution When running the first-time setup of Checkov in VS Code, an additional check should be run after the check for python3 --version to see if python --version returns the desired result.

mitchellresnick avatar Feb 15 '22 19:02 mitchellresnick

Only the microsoft store package provides python3: https://docs.python.org/3/using/windows.html#the-microsoft-store-package

Installing using https://www.python.org/downloads/windows/ releases does not provide python3.exe, only python.exe is provided.

willwh avatar Feb 23 '22 20:02 willwh

So I tried the route of setting an alias in my powershell profile:

Set-Alias -Name python3 -Value "C:\Program Files\Python38\python.exe"

Restarting VSC I still get the same plugin install failures.... however python3 --version works from the VSC terminal.... so it doesn't seem Aliases will be an option, with powershell as a default shell.

willwh avatar Mar 02 '22 17:03 willwh