![](/img/trans.png)
[英]TypeError: __init__() missing 1 required positional argument: 'to'
[英]TypeError: __init__() missing 1 required positional argument: 'parser' in slate3k
我正在嘗試使用 slate3k 從 pdf 文檔的前幾頁中提取一些信息,如下所示:
for i in range(table.shape[0]):
print(i)
download_path = pdf_dir + '/'+ table.iloc[i,6]
if(path.exists(download_path)):
if download_path.endswith('.pdf'):
file = open(download_path,'rb')
doc = slate3k.PDF(file)
doc = ' '.join(doc[:2])
doc = re.sub("\n","",doc)
我收到以下錯誤:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-10-474429c993a7> in <module>
12 if download_path.endswith('.pdf'):
13 file = open(download_path,'rb')
---> 14 doc = slate3k.PDF(file)
15 doc = ' '.join(doc[:2])
16 doc = re.sub("\n","",doc)
~\Anaconda3\lib\site-packages\slate3k\classes.py in __init__(self, file, password, just_text, check_extractable, char_margin, line_margin, word_margin)
57
58 if PYTHON_3:
---> 59 self.doc = PDFDocument()
60 self.parser.set_document(self.doc)
61 self.doc.set_parser(self.parser)
TypeError: __init__() missing 1 required positional argument: 'parser'
誰能幫我理解錯誤是什么? 我該如何解決這個問題?
我遇到了同樣的問題,出現這個錯誤的原因是pyinstaller。 好像干擾了slate3k的API。
我為解決這個問題做了什么
(可選 - 在我的情況下,我還必須卸載 pdfminer3,所以:) 3. pip 卸載 pdfminer3
現在它應該工作了。
編輯:似乎 pyinstaller 會導致相同的錯誤,因此您可以使用 pyinstaller = pdfminer 嘗試與上面相同的操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.