Skip to content

Commit

Permalink
support python3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
thehunmonkgroup committed May 15, 2024
1 parent 41c8a14 commit 2109f34
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions textract/parsers/pdf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
from .utils import ShellParser
from .image import Parser as TesseractParser

from distutils.spawn import find_executable
try:
from shutil import which
except ImportError:
from distutils.spawn import find_executable as which

class Parser(ShellParser):
"""Extract text from pdf files using either the ``pdftotext`` method
Expand Down Expand Up @@ -49,7 +52,7 @@ def extract_pdfminer(self, filename, **kwargs):
#Nested try/except loops? Not great
#Try the normal pdf2txt, if that fails try the python3
# pdf2txt, if that fails try the python2 pdf2txt
pdf2txt_path = find_executable('pdf2txt.py')
pdf2txt_path = which("pdf2txt.py")
try:
stdout, _ = self.run(['pdf2txt.py', filename])
except OSError:
Expand Down

0 comments on commit 2109f34

Please sign in to comment.