Is it possible to install Python from cmd on Windows? If so, how to do it?
-
1Yes for example u can use this Non-interactive InstallationThaian– Thaian2017-09-05 13:29:03 +00:00Commented Sep 5, 2017 at 13:29
-
Thanks @Thaian! Works great.madasionka– madasionka2017-09-07 12:40:28 +00:00Commented Sep 7, 2017 at 12:40
-
Does this answer your question? Install Python with cmd or powershellhalt9k– halt9k2023-03-02 11:14:51 +00:00Commented Mar 2, 2023 at 11:14
5 Answers
https://docs.python.org/3.6/using/windows.html#installing-without-ui
Installing Without UI: All of the options available in the installer UI can also be specified from the command line, allowing scripted installers to replicate an installation on many machines without user interaction. These options may also be set without suppressing the UI in order to change some of the defaults.
To completely hide the installer UI and install Python silently, pass the /quiet option. To skip past the user interaction but still display progress and errors, pass the /passive option. The /uninstall option may be passed to immediately begin removing Python - no prompt will be displayed.
All other options are passed as name=value, where the value is usually 0 to disable a feature, 1 to enable a feature, or a path.
Comments
I have used windows PowerShell to achieve this:
Download Python Exe File.. Feel free to edit 'URI' for the updated version of Python &
outFilefor your preferred Windows locationInvoke-WebRequest -UseBasicParsing -Uri \ 'https://www.python.org/ftp/python/3.11.0/python-3.11.0-amd64.exe' \ -OutFile 'c:/veera/python-3.11.0-amd64.exe'Install Python via Command Prompt
.\python-3.11.0-amd64.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0Set Python location
setx /M path "%path%;C:\Program Files\Python311\" $env:PATH =$env:PATH+";C:\Program Files\Python311\"
You're good to use Python from command prompt now :)
Comments
Another alternative is to use winget, e.g., winget install -e --id Python.Python.3.11. Should work out of the box in Windows 11 and modern installations of Windows 10 - according to the docs.
The winget command line tool enables users to discover, install, upgrade, remove and configure applications on Windows 10 and Windows 11 computers. This tool is the client interface to the Windows Package Manager service.
Comments
Assuming that you have python-installer.exe file you can run in in /passive mode in administrator window. Without administrator privileges you will be prompted
Do you want to allow this app to make changes to your device?
Powershell example could be:
$installer = "C:/tmp/python-3.7.6-amd64.exe"
& $installer /passive InstallAllUsers=1 PrependPath=1 Include_test=0
3 Comments
PATH will behave the same way in with both flags /passive or /quiet. If you have noticed different behaviour perhaps command like was not refreshed.For Windows
I was unable to find a way to Download python using just CMD but if you have python.exe in your system then you can use the below Method to install it (you can also make .bat file to automate it.)
Download the python.exe file on your computer from the official site.
Open CMD and change Your directory to the path where you have python.exe
Past this code in your Command prompt make sure to change the name with your file version In the below code(e.g python-3.8.5.exe)
python-3.6.0.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0
It will also set the path Variables.