エラーPythonのIronPDFの検索に失敗しました。
以下のコマンドを使用して.NET 6.0 SDKとIronPDFをpip経由でインストールしたと仮定します:
`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
# 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'
例えば
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")
理由
ほとんどのサードパーティライブラリは「site-packages」というディレクトリにインストールされます。このディレクトリは、Pythonのインストールディレクトリ内にあるか、仮想環境を使用している場合は仮想環境ディレクトリ内にあります。 こちらは、Python インタープリタによってアクセス可能なディレクトリです。
IronPDF は IronPdf.Slim
と IronPdf.Native.Chrome.Windows
の両方をインストールします。
オペレーティングシステムおよびPythonの設定により、正確な場所は異なる場合があります。