The term 'choco' is not recognized as the name of a cmdlet

Vedanth Pulipati 241 Reputation points
2022-02-15T12:27:34.88+00:00

i am trying to install some software's using the package manger chocolatey using in automation process in windows VM.
first using az command i have run the chocolatey

az vm run-command invoke -g $resourceGroupName -n $serverName --command-id RunpowerShellScript --scripts "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))"

after it's installed i tried to run python package

az vm run-command invoke --command-id RunPowerShellScript -g $resourceGroupName -n $serverName --scripts "choco install python -y"

while installing python i am facing the below issue

"message": "choco : The term 'choco' is not recognized as the name of a cmdlet

post python i have written cmd to install git using chocolatey git has been installed successfully but not sure why i am having issue with the python installation.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,805 questions
Microsoft System Center
Microsoft System Center
A suite of Microsoft systems management products that offer solutions for managing datacenter resources, private clouds, and client devices.
965 questions
0 comments No comments
{count} votes

Accepted answer
  1. XinGuo-MSFT 17,551 Reputation points
    2022-02-17T06:39:17.42+00:00

    Hi,

    The best way to install Python through Windows Command Prompt will be through Chocolatey (Windows Package Manageer).

    Steps to install python 3 will be as follows :-

    Open CMD using 'Run as Administrator'.

    Download and Install Chocolatey using the following command.

    @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
    

    Download and install python using the following command.

    choco install -y python3
    

    You can check the version to verify if Python was successfully installed as follows.

    python --version
    
    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Alan Kinane 16,901 Reputation points MVP
    2022-02-15T12:55:02.15+00:00

    I suspect the chocolatey installation did not complete. This runs a PowerShell script so you will need to change the execution policy first to allow this to run successfully.

    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.2

    2 people found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.