0

所以我制作了一个脚本,从网上(通过 selenium)下载 pdf,然后将所述 pdf 表转换为 excel 文件(通过 tabula)。我想与办公室的人分享这个脚本,但是我的团队没有任何 python/编程经验,所以我决定使用 Auto-Py-to-EXE 将 python 文件转换为可执行文件。然后我添加了一个文件(chromedriver),它成功下载了文件。

对于转换,我使用 tabula 将 PDF 转换为 csv 和 xlsx 文件。(在 notebook/.py 中,转换有效)但是当我将 .py 转换为 exe 并运行可执行文件时,我遇到了以下错误。

  File "tabula\io.py", line 80, in _run
  File "subprocess.py", line 493, in run
  File "subprocess.py", line 858, in __init__
  File "subprocess.py", line 1311, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "erc_scraper.py", line 126, in <module>
  File "tabula\io.py", line 322, in read_pdf
  File "tabula\io.py", line 91, in _run
tabula.errors.JavaNotFoundError: `java` command is not found from this Python process.Please ensure Java is installed and PATH is set for `java`
[24568] Failed to execute script 'erc_scraper' due to unhandled exception!

因此,我尝试按照此链接将我的 java 路径添加到环境路径。我已将 , 添加C:\Program Files (x86)\Java\jre6\binJAVA_HOME,JAVAPATH.

但是,现在当我尝试执行 EXE 文件时出现此错误。

Error from tabula-java:
Unable to access jarfile C:\Users\ur7634o\Desktop\erc_scraper\tabula\tabula-1.0.4-jar-with-dependencies.jar

subprocess.CalledProcessError: Command '['java', '-Dfile.encoding=UTF8', '-jar', 'C:\\Users\\ur7634o\\Desktop\\erc_scraper\\tabula\\tabula-1.0.4-jar-with-dependencies.jar', '--pages', 'all', '--guess', '--format', 'JSON', 'C:\\Users\\ur7634o\\Desktop\\ERC Data\\pdf\\qualified_contestable_customers_20220221-11-09-36.pdf']' 
returned non-zero exit status 1.
[25240] Failed to execute script 'erc_scraper' due to unhandled exception!

有什么建议下一步该怎么做?似乎可执行文件无法读取文件?我正在考虑如何让最终用户也能轻松做到这一点。我只是希望最终用户可以双击一些快捷方式来启动文件的下载和转换。

4

0 回答 0