Error al localizar IronPdf.Slim.dll

Suponiendo que ha instalado el SDK .NET 6.0 y IronPdf mediante pip utilizando el siguiente comando:

 pip install ironpdf

Es posible que se encuentre con la siguiente excepción al ejecutar el script Python:

Exception has occurred: Exception
Failed to locate IronPdf.Slim.dll at 'C:\Users\Name\AppData\Local\Programs\Python\Python311/IronPdf.Slim'. Please see https://ironpdf.com/troubleshooting/quick-ironpdf-troubleshooting/ para más información
  File "C:\Users\Name\OneDrive\Documents\IronPdfPythonNew\working\viewport.py", line 1, in <module>
    from ironpdf import *
Exception: Failed to locate IronPdf.Slim.dll at 'C:\Users\Name\AppData\Local\Programs\Python\Python311/IronPdf.Slim'. Please see https://ironpdf.com/troubleshooting/quick-ironpdf-troubleshooting/ para más información

Solución

El directorio que contiene IronPdf.Slim puede especificarse de la siguiente manera:

import sys
# This line should point to the root directory that contains the IronPdf.Slim folder.
# Users can determine this location by running `pip uninstall ironpdf` and pressing `N`.
sys.prefix = '/path/to/python/packages'
PYTHON

Por ejemplo

import sys
# This line should point to the root directory that contains the IronPdf.Slim folder.
# Users can determine this location by running `pip uninstall ironpdf` and pressing `N`.
sys.prefix = r'C:\Users\lyty1\AppData\Local\Programs\Python\Python311'

from ironpdf import *

# Instantiate Renderer
renderer = ChromePdfRenderer()

# Create a PDF from a URL or local file path
pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/")

# Export to a file or Stream
pdf.SaveAs("url.pdf")
PYTHON

Razón

La mayoría de las bibliotecas de terceros se instalan en un directorio llamado "site-packages", que se encuentra dentro del directorio de instalación de Python o dentro del directorio del entorno virtual si estás utilizando entornos virtuales. Este es el directorio accesible por su intérprete de Python.

IronPDF instalará tanto IronPdf.Slim como IronPdf.Native.Chrome.Windows.

La ubicación exacta puede variar dependiendo del sistema operativo y de tu configuración de Python.