Installation

Installera Aspose.BarCode FOSS för Python

Aspose.BarCode FOSS for Python is distributed as a pure-Python package on PyPI. There are no native extensions to compile, no system libraries to install, and no third-party runtime required.


Prerequisites

RequirementDetail
Python versioner3.12 or later
Förpackningsmanagerpip (bundna med CPython)
OperativsystemetWindows, macOS, Linux (alla plattformar som kör CPython)
Kompilera / bygga verktygIngen krävs
SystempaketIngen krävs

1. Install via pip

Det enklaste sättet att installera Aspose.BarCode FOSS är direkt från PyPI:

asposefoss/barcode is not yet published — build from source until it ships. See the project README for build instructions.

pip laddar ner och installerar paketet. ingen postinstallation krävs.

För att installera en fast version för reproducerbara byggen:

asposefoss/barcode is not yet published — build from source until it ships. See the project README for build instructions.

2. Set Up a Virtual Environment

Med hjälp av en virtuell miljö håller biblioteket isolerad från andra Python-projekt.

Skapa och aktivera en virtuell miljö:

# Create the environment
python -m venv .venv

# Activate on Linux / macOS
source .venv/bin/activate

# Activate on Windows (Command Prompt)
.venv\Scripts\activate.bat

# Activate on Windows (PowerShell)
.venv\Scripts\Activate.ps1

Installera biblioteket i den aktiverade miljön:

asposefoss/barcode is not yet published — build from source until it ships. See the project README for build instructions.

Registrera beroenden för reproducerbarhet:

pip freeze > requirements.txt

3. Verify the Installation

Efter installationen, verifiera att biblioteket importeras korrekt:

import aspose_barcode_foss as barcode

bc = barcode.code128("TEST")
print(f"Generated barcode with {bc.symbol.matrix.width}x{bc.symbol.matrix.height} modules")

Du kan också kontrollera den installerade versionen med pip:

pip show aspose-barcode-foss

Detta trycker versionen, författaren och licensen (MIT).


Snabb start: Generera en barkod

Följande skript genererar en kod 128 och sparar den som SVG:

import aspose_barcode_foss as barcode
from aspose_barcode_foss import RenderOptions

bc = barcode.code128("Hello World")
svg = bc.to_svg(options=RenderOptions(show_text=True))

with open("barcode.svg", "w") as f:
    f.write(svg)
print("Saved barcode.svg")

Generera en QR-kod och spara den som PNG:

import aspose_barcode_foss as barcode
from aspose_barcode_foss import QrOptions, QrErrorCorrectionLevel

bc = barcode.qr(
    "https://example.com",
    encode=QrOptions(error_correction_level=QrErrorCorrectionLevel.H),
)

with open("qr.png", "wb") as f:
    f.write(bc.to_png())
print("Saved qr.png")

Plattformsanteckningar

Windows, MacOS och Linux: Biblioteket är identiskt på alla plattformar. det finns inga plattformspecifika kodvägar eller binära förlängningar.

Docker / serverlös: Eftersom det inte finns systemförpackningsberoende, fungerar biblioteket inuti smala Docker-bilder (t.ex. python:3.12-slimutan att installera ytterligare paket.

CI/CD: Lägg till pip install aspose-barcode-foss till din CI-rörets beroendefas. Ingen ytterligare inställning krävs.


Nästa steg

  • Quickstart: Första arbetsbarkod med kod och render alternativ
  • License:• MIT licensinformation
  • Utvecklingsguide: Per-symbologi kodningsalternativ, rendering kontroller och kodexempel

Se även

 Svenska