Windows : commands.py [WinError 2]
This was done in a windows environment to run commands.py directly for speed.
I'm try command this.
$ python paper2html/commands.py "path-to-paper-file.pdf"
Is it a problem with my environment?
Thank you for the great software, it is exactly the behavior I was looking for. By the way, main.py (localhost conversion) and the Docker version work fine:)
Winpython310 Windows10 LTSC 1809
Microsoft Windows [Version 10.0.17763.2300]
(c) 2018 Microsoft Corporation. All rights reserved.
D:\>D:\----\Winpython310\python-3.10.0.amd64\Lib\site-packages\paper2html\commands.py "X:\---\001.pdf" --browser_path="D:\---\chrome.exe"
Traceback (most recent call last):
File "D:\----\Winpython310\python-3.10.0.amd64\Lib\site-packages\paper2html\commands.py", line 151, in <module>
fire.Fire(open_paper_htmls)
File "D:\----\Winpython310\python-3.10.0.amd64\lib\site-packages\fire\core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "D:\----\Winpython310\python-3.10.0.amd64\lib\site-packages\fire\core.py", line 466, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "D:\----\Winpython310\python-3.10.0.amd64\lib\site-packages\fire\core.py", line 681, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "D:\----\Winpython310\python-3.10.0.amd64\Lib\site-packages\paper2html\commands.py", line 147, in open_paper_htmls
raise e
File "D:\----\Winpython310\python-3.10.0.amd64\Lib\site-packages\paper2html\commands.py", line 143, in open_paper_htmls
for url in paper2html(pdf_filename, working_dir, line_margin_rate, verbose):
File "D:\----\Winpython310\python-3.10.0.amd64\Lib\site-packages\paper2html\commands.py", line 112, in paper2html
pdf_filename = clean_pdf(pdf_filename, fixed_dir)
File "D:\----\Winpython310\python-3.10.0.amd64\Lib\site-packages\paper2html\commands.py", line 75, in clean_pdf
subprocess.run(['pdftocairo', '-pdf', pdf_filename, new_pdf_filename])
File "D:\----\Winpython310\python-3.10.0.amd64\lib\subprocess.py", line 501, in run
with Popen(*popenargs, **kwargs) as process:
File "D:\----\Winpython310\python-3.10.0.amd64\lib\subprocess.py", line 966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "D:\----\Winpython310\python-3.10.0.amd64\lib\subprocess.py", line 1435, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] 指定されたファイルが見つかりません。
Thank you for using paper2html and sending a feedback.
Please try some codes because I've not found the reason yet.
If you fail installing Poppler, you will fail the command below.
> where.exe pdftocairo
In this case, you may success with readme-operations.
Or if Winpython requires path-portability or something, you will fail the script below.
import subprocess
subprocess.run(['pdftocairo', '-pdf', PDF_FILENAME, TMP_OUTPUT_FILENAME])
In this case, we need more investigation.
Thanks for the quick reply:)
where.exe pdftocairo
The result of where.exe showed a gitclone where I was in any folder.
Maybe,, it was done. setup.py
paper2html is gitclone from pip. _Poppler copied to the Paper2HTML folder.
subprocess.run(['pdftocairo', '-pdf', PDF_FILENAME, TMP_OUTPUT_FILENAME])
not work.
I will give up because the WinPython environment can not be changed...
thank you:)
Microsoft Windows [Version 10.0.17763.2300]
(c) 2018 Microsoft Corporation. All rights reserved.
D:\>D:\SOFT\dev\_runtime\_python\Winpython310\python-3.10.0.amd64\Lib\site-packages\paper2html\commands.py "X:\001.pdf"
Traceback (most recent call last):
File "D:\SOFT\dev\_runtime\_python\Winpython310\python-3.10.0.amd64\Lib\site-packages\paper2html\commands.py", line 152, in <module>
fire.Fire(open_paper_htmls)
File "D:\SOFT\dev\_runtime\_python\Winpython310\python-3.10.0.amd64\lib\site-packages\fire\core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "D:\SOFT\dev\_runtime\_python\Winpython310\python-3.10.0.amd64\lib\site-packages\fire\core.py", line 466, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "D:\SOFT\dev\_runtime\_python\Winpython310\python-3.10.0.amd64\lib\site-packages\fire\core.py", line 681, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "D:\SOFT\dev\_runtime\_python\Winpython310\python-3.10.0.amd64\Lib\site-packages\paper2html\commands.py", line 148, in open_paper_htmls
raise e
File "D:\SOFT\dev\_runtime\_python\Winpython310\python-3.10.0.amd64\Lib\site-packages\paper2html\commands.py", line 144, in open_paper_htmls
for url in paper2html(pdf_filename, working_dir, line_margin_rate, verbose):
File "D:\SOFT\dev\_runtime\_python\Winpython310\python-3.10.0.amd64\Lib\site-packages\paper2html\commands.py", line 113, in paper2html
pdf_filename = clean_pdf(pdf_filename, fixed_dir)
File "D:\SOFT\dev\_runtime\_python\Winpython310\python-3.10.0.amd64\Lib\site-packages\paper2html\commands.py", line 76, in clean_pdf
subprocess.run(['pdftocairo', '-pdf', PDF_FILENAME, TMP_OUTPUT_FILENAME])
NameError: name 'PDF_FILENAME' is not defined
Sorry for my omitted reply.
If you want to run commands.py directly in a windows environment, you have to install Poppler for Windows manually (it is not done with pip install). Download Poppler from the url in readme. And register the absolute path to the folder which contains pdftocairo in the environment variable.
You can check the success of this task by Command Prompt and that command.
where.exe pdftocairo
The expected result is displaying the folder path which contains pdftocairo.
After that, commands.py will be executed successfully.
Otherwise, please try the 'subprocess.run' script again. However you need to replace PDF_FILENAME and TMP_OUTPUT_FILENAME with specific paths. For example, the former is "X:---\001.pdf", and the latter is "X:---\001_converted.pdf".