Registry / http-networking / wget
library3.2pypypi✓ verified 25d ago

The `wget` Python library (version 3.2) is a pure Python download utility designed for simple file retrieval from HTTP URLs. It provides basic functionality to download files, optionally displaying a progress bar. It is distinct from the widely-used command-line utility GNU Wget, which offers more advanced features. The package's last update was in 2015, making it largely unmaintained compared to newer alternatives.

pip install wget
INSTALL
IMPORT
SIG · WGET
W
wget
http-networkingpythonv3.2
Install
2.3s avg
Import
85ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.090s · 19.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.3s · import 0.080s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

wget
import wget
from wget import download
While `download` is the primary function, importing `wget` directly and calling `wget.download()` is the common pattern, and `download` itself is not directly exposed as a top-level symbol for direct import.

This quickstart demonstrates how to download a file using the `wget.download()` function. The function returns the local filename of the downloaded content. The `out` parameter specifies the output filename, otherwise it defaults to the basename of the URL.

import wget import os url = 'https://www.python.org/static/img/python-logo.png' output_filename = 'python-logo.png' # Ensure clean state for demonstration if os.path.exists(output_filename): os.remove(output_filename) print(f"Downloading {url}...") filename = wget.download(url, out=output_filename) print(f"\nDownloaded to: {filename}")
Debug
Known issues
breakingThe `wget` library (version 3.2) has not been updated since October 2015 and is largely unmaintained. Consider using `py3-wget` for a more actively developed pure-Python solution or invoking the system's `wget` utility via Python's `subprocess` module for robust, feature-rich downloads.
fix
For new projects or if encountering issues, evaluate alternatives like `pip install py3-wget` or using `subprocess.run(['wget', 'url'])`.
affects: <=3.2
gotchaInstalling the Python `wget` package via `pip install wget` does NOT install the command-line utility `wget` or provide a wrapper to it. It's a separate, pure-Python implementation. If you intend to use the powerful GNU Wget command-line tool, you must install it separately on your operating system (e.g., `apt install wget` on Linux, `brew install wget` on macOS) and then use Python's `subprocess` module to call it.
fix
To use the CLI `wget` from Python, ensure the `wget` command-line utility is installed on your system, then use `import subprocess; subprocess.run(['wget', 'your_url'])`.
affects: All versions
gotchaThe `wget.download()` function returns the local filename of the downloaded file. It does not return the file content or a simple boolean indicating success. If the file already exists, it will rename the new download (e.g., `file.txt.1`).
fix
Always check the return value of `wget.download()` to get the actual path of the downloaded file. To control output filename, use the `out` parameter: `filename = wget.download(url, out='my_file.txt')`.
affects: All versions
gotchaWhen constructing URLs from user input or file reads (e.g., iterating lines from a text file), remember to strip any trailing newline characters (`\n`). If not removed, the URL passed to `wget.download()` will be invalid, often leading to download failures like HTTP 404 errors.
fix
Use `line.strip()` or `line.rstrip('\n')` to clean up strings before using them as URLs: `url = f"http://example.com/{line.strip()}.zip"`.
affects: All versions
gotchaThis pure Python `wget` library has fewer features than the GNU Wget command-line utility. It lacks advanced capabilities like recursive downloads, complex authentication, `robots.txt` adherence, and robust resume functionality for interrupted downloads (though `py3-wget` and the CLI `wget` support these).
fix
For advanced scenarios, consider using `subprocess` with the system's `wget` command or a more feature-rich HTTP client library like `requests`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'wget'
The 'wget' Python library is not installed in your current Python environment.
fix
pip install wget
AttributeError: module 'wget' has no attribute 'mirror'
The Python 'wget' library is a minimalist tool and does not implement advanced features like mirroring or recursive download found in the command-line GNU Wget utility.
fix
For advanced features, use the command-line GNU Wget via `subprocess` or switch to a more feature-rich Python HTTP client library like 'requests'.
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
The library's underlying `urllib.request` cannot verify the SSL certificate of the target server, often due to an outdated certificate store or the server using a certificate not trusted by default.
fix
While `import ssl; ssl._create_unverified_context()` can bypass this (use with caution, it's insecure), a more robust solution is to ensure your system's CA certificates are up-to-date or use a modern HTTP client like `requests`.
urllib.error.HTTPError: HTTP Error 404: Not Found
The server responded with an HTTP error status code (e.g., 404 Not Found, 500 Internal Server Error), indicating that the requested resource could not be found or processed.
fix
Verify the URL is correct and accessible. Check server logs if you control the server. Implement error handling using `try-except urllib.error.HTTPError`.
Upgrade
Version history
3.2latest on PyPI · released Oct 22, 2015
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
24
OpenAI (training)
1
Resources