Installation

Installation

Denna sida installerar Aspose.HTML FOSS för Python och verifierar installationen med en minimal DOM-omgång.


Prerequisites

RequirementDetail
Python3.10 eller senare
pipVilken som helst ny version
OperativsystemWindows, Linux eller macOS
Inbyggda beroendenIngen — ren Python implementation

1. Skapa en virtuell miljö (rekommenderas)

Håll installationen isolerad från systemet Python:

python -m venv .venv

Aktivera den — på Windows:

.venv\Scripts\activate

På Linux/macOS:

source .venv/bin/activate

2. Installera paketet

Installera den aktuella releasen (0.1.0) från PyPI:

git clone https://github.com/aspose-html-foss/Aspose.HTML-FOSS-for-Python.git
cd Aspose.HTML-FOSS-for-Python
pip install -e .

3. Verifiera installationen

Bygg ett en-element-dokument och läs tillbaka en beräknad stil — om detta skrivs ut utan fel fungerar installationen:

from aspose_html.dom import Document
from aspose_html.cssom import CSSStyleSheet

doc = Document()
el = doc.create_element("div")
el.set_attribute("id", "bar")
doc.append_child(el)

sheet = CSSStyleSheet()
sheet.replace_sync("#bar { color: blue }")
doc.attach_style_sheet(sheet)

print(el.get_computed_style().get_property_value("color"))

Nästa steg

Se även

 Svenska