Last updated: Apr 4, 2024
Reading timeยท4 min

wget command line utility on Windowswget command line utility with Pythonwget using Chocolatey on WindowsThe error "'wget' is not recognized as an internal or external command,
operable program or batch file" occurs when the wget package is not installed
on Windows. To solve the error, install wget before using the command.

The first option to use wget on Windows is to run the command in PowerShell.
To open PowerShell:

Use the wget command directly in PowerShell.
wget https://google.com -OutFile out.html

If you need to open PowerShell in a specific folder:
Shift and right-click in Explorer.
wget command.wget https://google.com -OutFile out.html
The wget command in PowerShell is an alias for the
Invoke-WebRequest
command.
Alternatively, you can install the wget package.
wget command line utility on WindowsTo download and install wget on Windows:
wget.exe by clicking on the
following link and clicking on
EXE.
If you are unsure whether your computer runs 32-bit or 64-bit:


path command to get the location where we have to copy the
wget.exe file.path

The screenshot shows that in my case the location is C:\Windows\system32. It
will likely be the same for you.
= after PATH and the first semicolon.wget.exe was
downloaded).cd "C:\Users\%USERNAME%\Downloads"
wget.exe file to the C:\Windows\system32 directory (or to your
specific PATH if it's different).copy "wget.exe" "C:\Windows\system32"
Close CMD and reopen it.
Now you can use the wget command on Windows.
wget https://google.com -o out.html
Make sure to restart your shell, otherwise, the wget command won't be
available.
wget command line utility with PythonOpen your CMD shell and run the following command to install wget using pip.
pip install wget # ๐๏ธ for Python v3 pip3 install wget # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install wget # ๐๏ธ for Python v3 python3 -m pip install wget # ๐๏ธ using py alias py -m pip install wget # ๐๏ธ If you get a permissions error pip install wget --user
Now you can run the wget command using the Python executable.
python -m wget https://google.com -o out.html py -m wget https://google.com -o out.html python3 -m wget https://google.com -o out.html

Alternatively, you can use the wget package in a Python script. Here are the
contents of a file named main.py that downloads a song using wget.
import wget url = 'http://www.futurecrew.com/skaven/song_files/mp3/razorback.mp3' filename = wget.download(url) print(filename)
You can run the file with the python main.py command.
python main.py
Alternatively, you can install wget using Chocolatey.
wget using Chocolatey on WindowsIf you have Chocolatey installed:
Click on the Search bar and type PowerShell.
Right-click on the PowerShell application and click "Run as administrator".

wget.choco install wget -y
To install Chocolatey:

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'))

choco to make sure Chocolatey is installed.
Now that you have Chocolatey installed, run the following command to install
wget.
choco install wget -y

Note that your shell should still be run using elevated permissions.
Now you should be able to use the wget command.
wget https://google.com -o out.html
If you still aren't able to use wget, close your shell and reopen it.
You can learn more about the related topics by checking out the following tutorials: