python-hosts
A hosts file manager library written in python
Decision gist · record as of 2026-08-14
Yes, if you need programmatic hosts file management. The package is stable (Production/Stable status), has no dependencies, and carries a permissive MIT license. However, the aging maintenance status (416 days since last release) means you should verify compatibility with your Python version before relying on it for critical automation.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction with no runtime dependencies.
- Maintenance status is aging—last release was 416 days ago, though the repository remains active with a recent commit on 2025-08-11.
License · maintenance · safety
MIT (permissive) — MIT license (permissive) means you can use, modify, and distribute this package freely with minimal restrictions.
last release 2025-06-24 (416 days) · last repo commit 2025-08-11 · 133 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 184,078 downloads/mo, #10,046 on PyPI
Alternatives
Verify before relying
pip install python-hosts
from python_hosts import Hosts, HostsEntry
hosts = Hosts(path='hosts_test')
entry = HostsEntry(entry_type='ipv4', address='1.2.3.4', names=['www.example.com'])
hosts.add([entry])
hosts.write()- Whether the package still works reliably on modern Python 3 versions given the aging maintenance status and lack of explicit requires_python specification.
What it is and what it does
python-hosts is a library for programmatic manipulation of the system hosts file. It lets you create, add, remove, and query hostname-to-IP mappings without manually editing the file, and supports importing entries from files or URLs. The library has no runtime dependencies and works as a pure Python module.
It's designed for system administrators and automation scripts that need to manage network hostname resolution at the OS level. You instantiate a Hosts object pointing to a hosts file, manipulate entries using HostsEntry objects, and write changes back to disk. The package remains compatible with Python 2.7 and modern Python 3 releases, though it has not seen a release in over a year.
Use it for
- Automate adding or removing hostname entries in CI/CD pipelines or deployment scripts.
- Bulk import hosts from a remote URL or file to synchronize local DNS resolution.
- Query the hosts file programmatically to check if a hostname or IP already exists before making changes.
- Merge new hostname aliases with existing entries without overwriting the entire hosts file.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need programmatic hosts file management.
The package is stable (Production/Stable status), has no dependencies, and carries a permissive MIT license. However, the aging maintenance status (416 days since last release) means you should verify compatibility with your Python version before relying on it for critical automation.
Install
python-hosts on PyPI
Before you install
Low install friction with no runtime dependencies. Maintenance status is aging—last release was 416 days ago, though the repository remains active with a recent commit on 2025-08-11.
License in practice
MIT license (permissive) means you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install python-hosts
from python_hosts import Hosts, HostsEntry
hosts = Hosts(path='hosts_test')
entry = HostsEntry(entry_type='ipv4', address='1.2.3.4', names=['www.example.com'])
hosts.add([entry])
hosts.write()
Verify before relying
- Whether the package still works reliably on modern Python 3 versions given the aging maintenance status and lack of explicit requires_python specification.
Package facts
| License | MIT permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Aging 416 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 184,078 / month, #10,046 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonTopic :: System :: NetworkingTopic :: System :: Operating System |
Evidence: python_hosts-1.1.2-py2-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “hosts file management”
- python-hostsManages hosts file entries programmatically—add, remove, import, and…
- sshconfsshconf reads and modifies SSH config files while preserving their…
- tinynetrcRead, parse, and write .netrc credential files with dictionary-style…
Give your agent the search over MCP, or paste the wish link into any chat.
More System packages
Provides a platform-independent file locking mechanism to coordinate access to files across processes and threads.
Distro provides a reliable, machine-readable API to query the Linux or BSD distribution name, version, codename, and other OS platform details, replacing Python's deprecated `platform.linux_distribution` function.
Install it if you need to detect or report the Linux/BSD distribution your code runs on.
psutil retrieves real-time information about running processes and system resources (CPU, memory, disks, network, sensors) across multiple operating systems, enabling system monitoring, process profiling, and resource management.
Pexpect spawns and controls interactive console applications by sending input and matching output patterns, automating tasks that would otherwise require manual interaction.
Provides asynchronous file I/O operations for asyncio programs, with automatic selection of the best available backend (io_uring, libaio, thread-based, or pure Python) depending on your system.
Portalocker provides cross-platform file locking with support for exclusive and shared locks, plus Redis-based distributed locks and process-aware PID file locking.
Install it if you need file or process coordination; the optional extras (pywin32, redis) are only required for specific lock types.
See also aiodiscover · netaddr · ipaddress · contentful_management · IP2Location · ipaddr · multiping · dnslib · icmplib · IPy