Skip to main content

pyportscanner

Check TCP port reachability on a single IPv4 host.

Python 3.11+ · Zero runtime dependencies

API reference · Changelog · PyPI

Installation

python -m pip install "pyportscanner>=0.4.0"

From a local checkout, run python -m pip install . in the repository root.

Quickstart

Check a local service on port 8000.

from pyportscanner import PortScanner

scanner = PortScanner(target_ports=[8000], timeout=0.5)
print(scanner.scan("127.0.0.1"))
{8000: 'OPEN'}

The example output assumes a service is listening. The result uses "CLOSE" when a connection fails, including when it times out. To try it with a listener that the example starts for you, run python examples/PortScanExample.py from an installed checkout.

Port selection

Input Ports checked
target_ports=[8000, 8443] The listed ports
target_ports=3 The first three ports in the built-in priority list
target_ports=None All 24 built-in ports

The legacy import from pyportscanner import pyscanner still works. Version 0.4 replaces the bundled Nmap service database with the built-in list. Pass explicit ports to keep the same targets across versions.

Develop

python -m pip install -e .
python -m unittest discover -s tests -v

The Python package lives in src/pyportscanner/, the API guide and icon in docs/, and runnable usage in examples/.

Build distributions

python -m pip install build twine
python -m build
python -m twine check --strict dist/*

The build writes a wheel and source distribution to dist/.

License

Apache-2.0. See the license text.

Metadata

Release files for pyportscanner 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyportscanner 0.4.0
File Size Uploaded Provenance Actions
pyportscanner-0.4.0.tar.gz 22.1 kB With provenance Details for pyportscanner-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyportscanner 0.4.0
File Interpreter ABI Platform Actions
pyportscanner-0.4.0-py3-none-any.whl Python 3 none any Details for pyportscanner-0.4.0-py3-none-any.whl

Total release size: 31.8 kB

Release files / pyportscanner-0.4.0.tar.gz

Download URL pyportscanner-0.4.0.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f4dc7e91d4b118e18088a7a6bbca52393e8d70a91b701c5a1d7137623a0abf9b
BLAKE2b-256 checksum
How to use checksums
79fcb690366b463e8eea04f5e7ded4840063e64b2162b4c7d18d9b20aaf992da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / pyportscanner-0.4.0-py3-none-any.whl

Download URL pyportscanner-0.4.0-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fdfcca4d666a20948a087e498917f61237080f47eb4211f63299d7515f5a9c3a
BLAKE2b-256 checksum
How to use checksums
b0a10fed557137a58cd468a689722d76addef3a7998bcc3db473deed0b8b23a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for pyportscanner 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyportscanner-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page