导入错误:无法从"borb.pdf.document 导入名称'Document'



我已经安装了'borb'使用pip install borb和安装后,我得到以下消息:

Requirement already satisfied: borb in c:usersdellappdatalocalprogramspythonpython37libsite-packages (2.0.25)
WARNING: You are using pip version 22.0.3; however, version 22.0.4 is available.
You should consider upgrading via the 'c:usersdellappdatalocalprogramspythonpython37python.exe -m pip install --upgrade pip' command.
Requirement already satisfied: qrcode[pil]>=6.1 in c:usersdellappdatalocalprogramspythonpython37libsite-packages (from borb) (7.3.1)
Requirement already satisfied: Pillow>=7.1.0 in c:usersdellappdatalocalprogramspythonpython37libsite-packages (from borb) (9.0.0)
Requirement already satisfied: requests>=2.24.0 in c:usersdellappdatalocalprogramspythonpython37libsite-packages (from borb) (2.25.1)
Requirement already satisfied: setuptools>=51.1.1 in c:usersdellappdatalocalprogramspythonpython37libsite-packages (from borb) (54.2.0)
Requirement already satisfied: fonttools>=4.22.1 in c:usersdellappdatalocalprogramspythonpython37libsite-packages (from borb) (4.33.3)
Requirement already satisfied: python-barcode>=0.13.1 in c:usersdellappdatalocalprogramspythonpython37libsite-packages (from borb) (0.13.1)
Requirement already satisfied: colorama in c:usersdellappdatalocalprogramspythonpython37libsite-packages (from qrcode[pil]>=6.1->borb) (0.4.4)
Requirement already satisfied: certifi>=2017.4.17 in c:usersdellappdatalocalprogramspythonpython37libsite-packages (from requests>=2.24.0->borb) (2020.12.5)
Requirement already satisfied: chardet<5,>=3.0.2 in c:usersdellappdatalocalprogramspythonpython37libsite-packages (from requests>=2.24.0->borb) (3.0.4)
Requirement already satisfied: idna<3,>=2.5 in c:usersdellappdatalocalprogramspythonpython37libsite-packages (from requests>=2.24.0->borb) (2.10)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:usersdellappdatalocalprogramspythonpython37libsite-packages (from requests>=2.24.0->borb) (1.26.4)

现在,如果我运行下面的代码,我将得到一个ImportError:

import typing  
from borb.pdf.document import Document  
from borb.pdf.pdf import PDF  
from borb.toolkit.text.simple_text_extraction import SimpleTextExtraction  

def main():
# variable to hold Document instance
doc: typing.Optional[Document] = None  
# this implementation of EventListener handles text-rendering instructions
l: SimpleTextExtraction = SimpleTextExtraction()  
# open the document, passing along the array of listeners
with open("PDFs/1.pdf", "rb") as in_file_handle:
doc = PDF.loads(in_file_handle, [l])  

# were we able to read the document?
assert doc is not None  
# print the text on page 0
print(l.get_text(0))  
if __name__ == "__main__":
main()

我得到以下错误:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~AppDataLocalTemp/ipykernel_5400/405389204.py in <module>
1 import typing
----> 2 from borb.pdf.document import Document
3 from borb.pdf.pdf import PDF
4 from borb.toolkit.text.simple_text_extraction import SimpleTextExtraction
5 
ImportError: cannot import name 'Document' from 'borb.pdf.document' (C:UsersDELLAppDataLocalProgramsPythonPython37libsite-packagesborbpdfdocument__init__.py)

关于如何解决这个问题的任何输入…?

请从borb.pdf中导入Documentclass
用法:from borb.pdf import Document

from borb.pdf.document.document import Document

"Document"是来自borb.pdf.document.document.py的类

相关内容

  • 没有找到相关文章

最新更新