錯誤:在 Python 中找不到 IronPDF
This article was translated from English: Does it need improvement?
TranslatedView the article in English
假設您已使用以下命令透過 pip 安裝了 .NET 6.0 SDK 和 IronPdf:
pip install ironpdf
執行 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解決方案
包含IronPdf.Slim目錄可以如下指定:
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
例如
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
原因
大多數第三方函式庫都安裝在名為"site-packages"的目錄中,該目錄位於 Python 安裝目錄中,或者如果您使用虛擬環境,則位於虛擬環境目錄中。 這是你的Python解釋器可以存取的目錄。
IronPDF 將同時安裝IronPdf.Slim和IronPdf.Native.Chrome.Windows 。
具體位置可能因作業系統和 Python 配置而異。







