Python quick start for the Windows Barcode Scanner SDK
Build a lightweight barcode scanner in Python for Windows. The command-line interface accepts a single image path as input, and the Scanbot SDK license key is embedded directly in the source code.
Create the project and install the Scanbot SDK
1. Install Python
Install Python 3 and ensure python and pip are available in your terminal.
2. Create and activate a virtual environment
python -m venv .env
.\.env\Scripts\Activate.ps1
pip install --upgrade pip setuptools wheel
3. Install the Scanbot SDK
Replace <SCANBOT_SDK_VERSION> with the version number you want to install. Pick the wheel that matches the architecture of your Python installation.
- x64 (win_amd64)
- x86 (win32)
$env:SCANBOT_SDK_VERSION="<SCANBOT_SDK_VERSION>"
pip install "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv$env:SCANBOT_SDK_VERSION/scanbotsdk-$env:SCANBOT_SDK_VERSION-py3-none-win_amd64.whl"
$env:SCANBOT_SDK_VERSION="<SCANBOT_SDK_VERSION>"
pip install "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv$env:SCANBOT_SDK_VERSION/scanbotsdk-$env:SCANBOT_SDK_VERSION-py3-none-win32.whl"
4. Verify installation
python -c "import scanbotsdk; print('scanbotsdk OK')"
Project layout
Create a minimal project folder with a single entry-point script:
mkdir barcode-quickstart-python
ni barcode-quickstart-python\main.py -ItemType File
Initialize the Scanbot SDK
Before using any feature of the Scanbot SDK in Python, initialize the SDK.
import scanbotsdk
from scanbotsdk import LicenseStatus
SCANBOT_LICENSE_KEY = "<SCANBOTSDK-LICENSE-KEY>"
def initialize_sdk() -> None:
scanbotsdk.initialize(SCANBOT_LICENSE_KEY)
license_info = scanbotsdk.get_license_info()
print(f"License Status: {license_info.status}")
if license_info.status != LicenseStatus.OKAY:
raise SystemExit("Invalid or expired license. Exiting.")
Create and run the Barcode Scanner
After successful initialization, create a scanner configuration and run it on an ImageRef.
def run_barcode_scanner(image: ImageRef):
config = BarcodeScannerConfiguration()
scanner = BarcodeScanner(configuration=config)
result = scanner.run(image=image)
if not result.barcodes:
print("No barcodes found.")
return
for idx, barcode in enumerate(result.barcodes, 1):
print(f"{idx}) {barcode.text} [{barcode.format}]")
Complete example
import sys
import scanbotsdk
from scanbotsdk import (
LicenseStatus,
ImageRef,
BarcodeScanner,
BarcodeScannerConfiguration,
)
SCANBOT_LICENSE_KEY = "<SCANBOTSDK-LICENSE-KEY>"
def initialize_sdk() -> None:
scanbotsdk.initialize(SCANBOT_LICENSE_KEY)
license_info = scanbotsdk.get_license_info()
print(f"License Status: {license_info.status}")
if license_info.status != LicenseStatus.OKAY:
raise SystemExit("Invalid or expired license. Exiting.")
def run_barcode_scanner(image: ImageRef) -> None:
config = BarcodeScannerConfiguration()
scanner = BarcodeScanner(configuration=config)
result = scanner.run(image=image)
if not result.barcodes:
print("No barcodes found.")
return
for idx, barcode in enumerate(result.barcodes, 1):
print(f"{idx}) {barcode.text} [{barcode.format}]")
def main():
if len(sys.argv) < 2:
print("Usage: python main.py <image_path>")
return
image_path = sys.argv[1]
initialize_sdk()
image = ImageRef.from_path(image_path)
run_barcode_scanner(image)
if __name__ == "__main__":
main()
Run
python main.py C:\path\to\image_with_barcodes.jpg
🚀 That's it! You've built a minimal barcode scanner in Python on Windows.
💡 In this quick start guide, we use the SDK's default scanner settings. However, you can freely customize the configuration, supported barcode types, and performance options.
Get in touch
If you need further information or are interested in licensing the Scanbot SDK, please get in touch with our solution experts.
Scanbot SDK is part of the Apryse SDK product family
A mobile scan is just the start. With Apryse SDKs, you can expand mobile workflows into full cross‑platform document processing. Whether you need to edit PDFs, add secure digital signatures, or use a fast, customizable document viewer and editor, Apryse gives you the tools to build powerful features quickly.
Learn more
