无法在langchain中阅读PDF文档

问题描述 投票:0回答:1

尝试在 langchain 中阅读 PDF 文档,但出现以下错误。 Pypdf 也已安装。可以请教一下如何解决吗

langchain.document_loaders.PyPDFLoader

file_path="C:/Users/gbzr7856/Desktop/LanChain/Data Science from Scratch.pdf"

pdf_loader = PyPDFLoader(file_path=file_path)

ValueError Traceback(最近一次调用最后一次) 单元格 In[46],第 1 行 ----> 1 pdf_loader = PyPDFLoader(file_path=file_path)

文件 ~\Anaconda3 nvs\langchain\Lib\site-packages\langchain\document_loaders\pdf.py:157,在 PyPDFLoader 中。init(self、file_path、密码、标题、extract_images) 153 除了导入错误: 154 引发导入错误( 155“未找到pypdf包,请使用“”安装它

pip install pypdf
” 156) --> 157 super().init(file_path, headers=headers) 第158章

文件 ~\Anaconda3 nvs\langchain\Lib\site-packages\langchain\document_loaders\pdf.py:100,在 BasePDFLoader 中。

init(self, file_path, headers) 98 self.file_path = str(temp_pdf) 99 elif 不是 os.path.isfile(self.file_path): --> 100 raise ValueError("文件路径 %s 不是有效的文件或 url" % self.file_path)

ValueError:文件路径 C:/Users/gbzr7856/Desktop/LanChain/Data Science from Scratch.pdf 不是有效的文件或网址

i want to read the PDF document


    

pdf loader langchain
1个回答
0
投票
从异常情况来看,你应该采取两个行动。

  1. pip install pypdf
    
    
  2. file_path
     未正确指定。试试这个
from langchain_community.document_loaders import PyPDFLoader loader = PyPDFLoader("example_path/layout-parser-paper.pdf") # Don't forget the double-quote pages = loader.load_and_split()
    
© www.soinside.com 2019 - 2024. All rights reserved.