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

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
4 min

banner

# Table of Contents

  1. 'wget' is not recognized as an internal or external command
  2. Installing the wget command line utility on Windows
  3. Installing and using the wget command line utility with Python
  4. Install wget using Chocolatey on Windows

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

The 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.

wget is not recognized as internal or external command

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

To open PowerShell:

  1. Click on the Search bar and type "PowerShell".

start powershell

  1. Click on the "Windows PowerShell" application.

Use the wget command directly in PowerShell.

PowerShell
wget https://google.com -OutFile out.html

windows powershell wget command

If you need to open PowerShell in a specific folder:

  1. Open the folder in a window.
  2. Press Shift and right-click in Explorer.

windows open powershell window here

  1. Click on "Open PowerShell window here".
  2. Run the wget command.
PowerShell
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.

# Installing the wget command line utility on Windows

To download and install wget on Windows:

  1. Download wget.exe by clicking on the following link and clicking on EXE.

download wget windows

If you are unsure whether your computer runs 32-bit or 64-bit:

  • Click on the Start button, then click Settings > System > About.
  • Look at the value of "System type".

windows check if 32 64 bit

  1. Open CMD as an administrator.

run cmd as administrator

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

windows path command

The screenshot shows that in my case the location is C:\Windows\system32. It will likely be the same for you.

We're looking at the value between the equal sign = after PATH and the first semicolon.
  1. Change to the Downloads directory (or to the directory where wget.exe was downloaded).
cmd
cd "C:\Users\%USERNAME%\Downloads"
  1. Copy the wget.exe file to the C:\Windows\system32 directory (or to your specific PATH if it's different).
cmd
copy "wget.exe" "C:\Windows\system32"
  1. Close CMD and reopen it.

  2. Now you can use the wget command on Windows.

shell
wget https://google.com -o out.html

Make sure to restart your shell, otherwise, the wget command won't be available.

# Installing and using the wget command line utility with Python

Open your CMD shell and run the following command to install wget using pip.

cmd
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.

cmd
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

using wget with python executable

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.

main.py
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.

cmd
python main.py

Alternatively, you can install wget using Chocolatey.

# Install wget using Chocolatey on Windows

If you have Chocolatey installed:

  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

  1. Run the following command to install wget.
PowerShell
choco install wget -y
If you don't have Chocolatey installed, you have to install it first.

To install Chocolatey:

  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

Now that you have Chocolatey installed, run the following command to install wget.

PowerShell
choco install wget -y

chocolatey install wget

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

Now you should be able to use the wget command.

shell
wget https://google.com -o out.html

If you still aren't able to use wget, close your shell and reopen it.

# 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.

Copyright ยฉ 2024 Borislav Hadzhiev