{"id":26978,"library":"factur-x","title":"Factur-X","description":"A Python library for generating Factur-X (FR) and Order-X (DE) electronic invoices and orders in PDF/A-3 format with embedded XML. Current version 4.2, supports Python >=3.7. Release cadence is irregular.","status":"active","version":"4.2","language":"python","source_language":"en","source_url":"https://github.com/akretion/factur-x","tags":["Factur-X","electronic invoice","Order-X","PDF/A-3","XML"],"install":[{"cmd":"pip install factur-x","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"XML processing for invoice XML","package":"lxml","optional":false},{"reason":"PDF generation (legacy, consider replacement)","package":"pyPdf","optional":false},{"reason":"Image handling for QR codes","package":"Pillow","optional":true}],"imports":[{"note":"Dash in library name, underscore in import not supported","wrong":"from factur_x import FacturX","symbol":"FacturX","correct":"from facturx import FacturX"},{"note":"Correct import for Order-X","symbol":"OrderX","correct":"from facturx import OrderX"}],"quickstart":{"code":"from facturx import FacturX\n\n# Create a Factur-X invoice\ninvoice = FacturX(\n    xml_file='invoice.xml',\n    pdf_file='output.pdf',\n    logo='logo.png',  # optional\n)\ninvoice.generate()\n\nprint('Invoice generated successfully')\n","lang":"python","description":"Basic invoice generation from an XML file."},"warnings":[{"fix":"Update calls to `FacturX(xml_file='...', pdf_file='...').generate()`","message":"Version 4.0+ changed the API: removed the old `FacturX.generate()` without arguments. Now you must pass `xml_file` and `pdf_file`.","severity":"breaking","affected_versions":">=4.0"},{"fix":"Replace `pip install factur-x` with `pip install factur-x[pdf]` for pypdf, or manually install `pypdf`.","message":"The `pyPdf` dependency is deprecated. Use `PyPDF2` or `pypdf` as a drop-in replacement.","severity":"deprecated","affected_versions":">=4.0"},{"fix":"Validate your XML against the Factur-X schema before passing to the library.","message":"The XML file must comply with the Factur-X standard (e.g., EN 16931). Non-compliant XML will raise validation errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `pip install factur-x` (dash in pip), then import with `from facturx import FacturX`.","cause":"Import uses hyphens in the package name, but Python packages cannot have hyphens. The correct import uses the canonical name without hyphen: `facturx`.","error":"ModuleNotFoundError: No module named 'factur_x'"},{"fix":"Check the XML against the official Factur-X specifications, particularly the namespace `urn:factur-x:pdfa:CrossIndustryDocument:1p0`.","cause":"The XML file does not conform to the Factur-X schema (e.g., missing required fields, wrong namespaces).","error":"ValueError: Factur-X XML is not valid"},{"fix":"Upgrade to latest version: `pip install --upgrade factur-x`. If still fails, check installed version with `pip show factur-x`.","cause":"Possibly using a very old version (pre-4.0) where the class name was different or not exported.","error":"ImportError: cannot import name 'FacturX' from 'facturx'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}