Python 我传递了file对象,但仍然得到slate3k的解析错误

Python 我传递了file对象,但仍然得到slate3k的解析错误,python,python-3.x,slate,Python,Python 3.x,Slate,我正在尝试使用“slate3k”读取pdf文件的文本数据。我觉得很好。但是我得到了一个解析错误 我一直在使用“python3.7” 以上代码的输出应该是pdf格式的文本。但实际产出是 "Traceback (most recent call last): File "/home/am-it/Desktop/PythonLearning/pdf_practice/invoslate.py", line 4, in <module> doc = slate3k.PDF(fi

我正在尝试使用“slate3k”读取pdf文件的文本数据。我觉得很好。但是我得到了一个解析错误

我一直在使用“python3.7”

以上代码的输出应该是pdf格式的文本。但实际产出是

 "Traceback (most recent call last):
  File "/home/am-it/Desktop/PythonLearning/pdf_practice/invoslate.py", line 4, in <module>
    doc = slate3k.PDF(file)
  File "/home/administrator/.local/lib/python3.7/site-packages/slate3k/classes.py", line 59, in __init__
    self.doc = PDFDocument()
TypeError: __init__() missing 1 required positional argument: 'parser'" 
“回溯(最近一次呼叫最后一次):
文件“/home/am it/Desktop/PythonLearning/pdf_practice/invoslate.py”,第4行,在
doc=slate3k.PDF(文件)
文件“/home/administrator/.local/lib/python3.7/site packages/slate3k/classes.py”,第59行,在__
self.doc=PDFDocument()
TypeError:\uuuu init\uuuuu()缺少1个必需的位置参数:“解析器”
我已传递了正确的文件对象,但仍然出现错误。所以请告诉我,伙计, 在守则的这部分: 打开(“/home/am it/Desktop/PythonLearning/pdf\u practice/invoice-1.pdf”,“rb”)作为文件:

您必须写入文件名加上扩展名,而不是路径。 那么,试试这个:
使用open(“invoice-1.pdf”、“rb”)作为文件:

Mine可以很好地使用单引号,并且打印不缩进

将slate3k作为slt导入
将open('pdfPythonTest.pdf','rb')作为f:
extracted_text=slt.PDF(f)
打印(提取的文本)

希望这有帮助

看起来slate3k中可能有错误,或者您使用的是不兼容版本的pdfminer。谢谢@iguanaaut…我卸载了pdfminer。六…它开始工作了。这不正确。您可以包括路径以及文件名和扩展名。
 "Traceback (most recent call last):
  File "/home/am-it/Desktop/PythonLearning/pdf_practice/invoslate.py", line 4, in <module>
    doc = slate3k.PDF(file)
  File "/home/administrator/.local/lib/python3.7/site-packages/slate3k/classes.py", line 59, in __init__
    self.doc = PDFDocument()
TypeError: __init__() missing 1 required positional argument: 'parser'"