【问题标题】:converting Python Script to EXE with (Tabula) .JavaNotFoundError using Auto Py to EXE使用 Auto Py 将 Python 脚本转换为 EXE,使用 (Tabula) .JavaNotFoundError 到 EXE
【发布时间】:2022-06-18 05:24:41
【问题描述】:

所以我制作了一个脚本,从网上(通过 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!

所以我尝试按照link 将我的 java 路径添加到环境路径。我已将C:\Program Files (x86)\Java\jre6\bin 添加到JAVA_HOMEJAVAPATH

但是,现在我在尝试执行 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!

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

【问题讨论】:

    标签: python java tabula auto-py-to-exe


    【解决方案1】:

    我今天刚遇到这个问题,我试过了,它成功了:

    • 编译可执行文件时,使用“一个目录”选项
    • 编译完成后,进入 tabula 包安装目录,将 tabula 文件夹复制到 auto-py-exe 的输出文件夹中 tabula package location

    应该可以。正如错误所示,缺少的是“tabula\tabula-1.0.4-jar-with-dependencies.jar”。我不知道为什么 auto-py-to-exe 不像其他包那样带上 tabula 包,但我不得不手动带上它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-05
      • 2018-02-13
      • 1970-01-01
      • 1970-01-01
      • 2023-01-04
      • 1970-01-01
      • 2017-07-29
      • 2020-09-22
      相关资源
      最近更新 更多