Failed to locate IronPdf.Slim.dll
Assuming you have installed the .NET 6.0 SDK and IronPdf via pip using the following command:
pip install ironpdf
You may encounter the exception below upon executing the Python script:
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/ 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
The directory that contains IronPdf.Slim
can be specified as follows:
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'
For Example
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")
Reason
Most third-party libraries are installed in a directory called "site-packages," which is located either within the Python installation directory or within the virtual environment directory if you're using virtual environments. This is the directory accessible by your Python interpreter.
IronPDF will install both IronPdf.Slim
and IronPdf.Native.Chrome.Windows
.
The exact location can vary depending on the operating system and your Python configuration.