2016-11-16 4 views
0

Я пытаюсь извлечь текст из PDF-файла с помощью slate модуля, как показано в этомизвлечения текста из PDF с помощью python3

$sudo pip install https://codeload.github.com/timClicks/slate/zip/master 
Collecting https://codeload.github.com/timClicks/slate/zip/master 
    Downloading https://codeload.github.com/timClicks/slate/zip/master 
Requirement already satisfied: distribute in /usr/lib/python3.5/site-packages (from slate==0.5.2) 
Requirement already satisfied: pdfminer3k in /usr/lib/python3.5/site-packages (from slate==0.5.2) 
Requirement already satisfied: setuptools>=0.7 in /usr/lib/python3.5/site-packages (from distribute->slate==0.5.2) 
Requirement already satisfied: pytest>=2.0 in /usr/lib/python3.5/site-packages (from pdfminer3k->slate==0.5.2) 
Requirement already satisfied: ply>=3.4 in /usr/lib/python3.5/site-packages (from pdfminer3k->slate==0.5.2) 
Requirement already satisfied: py>=1.4.29 in /usr/lib/python3.5/site-packages (from pytest>=2.0->pdfminer3k->slate==0.5.2) 
Installing collected packages: slate 
    Found existing installation: slate 0.3 
    Uninstalling slate-0.3: 
     Successfully uninstalled slate-0.3 
    Running setup.py install for slate ... done 
Successfully installed slate-0.5.2 

и я пытаюсь:

#!/usr/bin/python3 
import slate 

with open('/var/tmp/PhysRevB.93.014203.pdf') as fp: 
    doc = slate.PDF(fp) 
print(len(doc)) 
print(doc[0]) 

, который дает мне ошибку :

$python3 tstslt.py 
Traceback (most recent call last): 
    File "tstslt.py", line 2, in <module> 
    import slate 
    File "/usr/lib/python3.5/site-packages/slate/__init__.py", line 66, in <module> 
    from .classes import PDF 
    File "/usr/lib/python3.5/site-packages/slate/classes.py", line 25, in <module> 
    import utils 
ImportError: No module named 'utils' 

я могу извлечь текст с помощью PyPDF2, но выглядит, если с поздно лучше.

ответ

0

Согласно this issue один из dependecies Шифер в (pdfminer) не поддерживает Python3

(...)

The "pdfminer" that is required does not work because it is currently incompatible with python 3.5.

It says so on their readme:

https://github.com/euske/pdfminer

"Install Python 2.6 or newer. (Python 3 is not supported.)"

+0

Хотя эта ссылка может ответить на этот вопрос, то лучше включить основные части ответа здесь и предоставить ссылку Справка. Ответные ссылки могут стать недействительными, если связанная страница изменится. - [Из обзора] (/ review/low-quality-posts/17579044) –

Смежные вопросы