Error: Failed to Locate IronPDF in Python

This article was translated from English: Does it need improvement?
Translated
View the article in English

En supposant que vous ayez installé le SDK .NET 6.0 et IronPdf via pip en utilisant la commande suivante :

pip install ironpdf

Vous pourriez rencontrer l'exception ci-dessous lors de l'exécution du 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 /troubleshooting/quick-ironpdf-troubleshooting/ for more information
  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/ for more information

Solution

Le répertoire contenant IronPdf.Slim peut être spécifié comme suit :

import sys
# Set the path to include the directory containing the IronPdf.Slim files.
# Users can determine this location by running `pip uninstall ironpdf` and pressing `N` to view the installation path.
sys.path.append('/path/to/python/packages')
import sys
# Set the path to include the directory containing the IronPdf.Slim files.
# Users can determine this location by running `pip uninstall ironpdf` and pressing `N` to view the installation path.
sys.path.append('/path/to/python/packages')
PYTHON

Par exemple

import sys
# Add the directory of the IronPdf installation to the path for module resolution.
# This should point to the root directory of where IronPdf is installed.
sys.path.append(r'C:\Users\lyty1\AppData\Local\Programs\Python\Python311\Lib\site-packages')

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")
import sys
# Add the directory of the IronPdf installation to the path for module resolution.
# This should point to the root directory of where IronPdf is installed.
sys.path.append(r'C:\Users\lyty1\AppData\Local\Programs\Python\Python311\Lib\site-packages')

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

Raison

La plupart des bibliothèques tierces sont installées dans un répertoire appelé "site-packages", qui se trouve soit dans le répertoire d'installation de Python, soit dans le répertoire de l'environnement virtuel si vous utilisez des environnements virtuels. C'est le répertoire accessible par votre interpréteur Python.

IronPDF installera à la fois IronPdf.Slim et IronPdf.Native.Chrome.Windows.

L'emplacement exact peut varier en fonction du système d'exploitation et de votre configuration Python.

Curtis Chau
Rédacteur technique

Curtis Chau détient un baccalauréat en informatique (Université de Carleton) et se spécialise dans le développement front-end avec expertise en Node.js, TypeScript, JavaScript et React. Passionné par la création d'interfaces utilisateur intuitives et esthétiquement plaisantes, Curtis aime travailler avec des frameworks modernes ...

Lire la suite
Prêt à commencer?
Version : 2025.9 vient de sortir