'choco' is not recognized as an internal or external command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
3 min

banner

# 'choco' is not recognized as an internal or external command

The error "'choco' is not recognized as an internal or external command" occurs for 2 main reasons:

  1. Not having chocolatey installed on your machine.
  2. Not having chocolatey added to your system's PATH environment variable.

choco is not recognized as internal or external command

shell
'choco' is not recognized as an internal or external command, operable program or batch file The term 'choco' is not recognized as the name of a cmdlet.

First, make sure you have Chocolatey installed:

  1. Open PowerShell as an administrator.

run powershell as administrator

  1. Run the following command.
PowerShell
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

windows install chocolatey

  1. Wait for the command to complete.
  2. Type choco to make sure Chocolatey is installed.

windows verify chocolatey installed

Verify that chocolatey is installed by running the following command.

PowerShell
choco

Note that your shell should still be run using elevated permissions.

  1. If you get the error "The term 'choco' is not recognized as the name of a cmdlet", close PowerShell, open it in a new Windows as an administrator and run the choco command again.
If the error persists, you have to add chocolatey to your PATH environment variable.
  1. Click on the Search bar and type "chocolatey".

  2. Right-click on the "chocolatey" application and click "Open file location".

search chocolatey

  1. Select the location of the choco executable and copy it.

copy chocolatey location in explorer

For me the location is C:\ProgramData\chocolatey\bin and it will likely be similar to your path.

We are looking for the directory that contains the chocolatey.exe (executable) file.
  1. Click on the Search bar, type "Environment variables" and then click on "Edit the system environment variables".

edit system environment variables

  1. Click on the "Environment Variables" button.

click environment variables

  1. In the "System variables" section, select the "Path" variable and click "Edit".

select path and click edit

  1. Click "New" and paste the path to the chocolatey executable that you previously copied.

click new and paste path

  1. Click on "OK" twice to confirm the changes.

  2. Close all instances of Command Prompt and PowerShell.

Note that you must restart Command Prompt and PowerShell for the changes to take effect.

You might also have to restart your PC, but that's not always necessary.

To run PowerShell as an administrator:

  1. Click on the Search bar and type "PowerShell".
  2. Right-click on the "PowerShell" application and click "Run as administrator".

run powershell as administrator

Verify that chocolatey is installed by running the following command.

PowerShell
choco

windows verify chocolatey installed

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.