In my Python
Project, I'm trying to use refextract to parse some data from a pdf file, But I'm unable to use its extract_references_from_file
feature.
I'm using sample code as mentioned on site:
from refextract import extract_references_from_file
references = extract_references_from_file('C02-1025.pdf')
print(references[0])
And getting this error;
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
I've tried different ways to pass file path like these;
references = extract_references_from_file(r"F:\project\python\C02-1025.pdf")
references = extract_references_from_file("F:\\project\\python\\C02-1025.pdf")
but nothing worked.
I am using Python 3.7.2 and it is 64 bits.
Here is full Traceback of error:
Traceback (most recent call last):
File "refext.py", line 16, in <module>
references = extract_references_from_file(r"F:\project\python\C02-1025.pdf")
File "C:\Users\Username\AppData\Local\Programs\Python\Python37\lib\site-packages\refextract\references\api.py", line 128, in extract_references_from_file
docbody = get_plaintext_document_body(path)
File "C:\Users\Username\AppData\Local\Programs\Python\Python37\lib\site-packages\refextract\references\engine.py", line 1412, in get_plaintext_document_body
textbody = convert_PDF_to_plaintext(fpath, keep_layout)
File "C:\Users\Username\AppData\Local\Programs\Python\Python37\lib\site-packages\refextract\documents\pdf.py", line 457, in convert_PDF_to_plaintext
if not os.path.isfile(CFG_PATH_PDFTOTEXT):
File "C:\Users\Username\AppData\Local\Programs\Python\Python37\lib\genericpath.py", line 30, in isfile
st = os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
The refextract library relies upon the pdftotext command line utility. but when I try to install it
pip install pdftotext
It gave me this error
ERROR: Command errored out with exit status 1:
command: 'c:\users\usernamem\appdata\local\programs\python\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\USER~1\\AppData\\Local\\Temp\\pip-install-l_9a5zt6\\pdftotext\\setup.py'"'"'; __file__='"'"'C:\\Users\\USER~1\\AppData\\Local\\Temp\\pip-install-l_9a5zt6\\pdftotext\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\USER~1\AppData\Local\Temp\pip-record-gpha3woc\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\username\appdata\local\programs\python\python37\Include\pdftotext'
cwd: C:\Users\USER~1\AppData\Local\Temp\pip-install-l_9a5zt6\pdftotext\
Complete output (11 lines):
WARNING: pkg-config not found--guessing at poppler version.
If the build fails, install pkg-config and try again.
running install
running build
running build_ext
building 'pdftotext' extension
creating build
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -DPOPPLER_CPP_AT_LEAST_0_30_0=1 "-Ic:\users\username\appdata\local\programs\python\python37\include" "-Ic:\users\username\appdata\local\programs\python\python37\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" /EHsc /Tppdftotext.cpp /Fobuild\temp.win-amd64-3.7\Release\pdftotext.obj -Wall
error: command 'cl.exe' failed: No such file or directory
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\username\appdata\local\programs\python\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\USER~1\\AppData\\Local\\Temp\\pip-install-l_9a5zt6\\pdftotext\\setup.py'"'"'; __file__='"'"'C:\\Users\\USER~1\\AppData\\Local\\Temp\\pip-install-l_9a5zt6\\pdftotext\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\USER~1\AppData\Local\Temp\pip-record-gpha3woc\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\username\appdata\local\programs\python\python37\Include\pdftotext' Check the logs for full command output.