是否可以在便携式IDE上使用Tabula Py



我是python的新手,正在为我在python中的工作设置一些自动化,其中一部分是从pdf文件中的表中提取数据。简短的版本是,无论我如何尝试和查找什么,我都无法让Tabula Py在我的便携式驱动器上查看java的路径。

我使用便携式IDE设置,因为我在工作电脑上没有管理员权限。

Tabula Py抛出了常见的找不到Java的错误,请确保它在您的PATH错误消息中。我使用的是Python Portable和jPortable,它们安装在一个公共目录中,Spyder Portable作为IDE。我已经在Tabula和Tabula Py上多次运行pip安装和卸载。我还为sys.path.append运行了import-sys,将文件路径添加到我的Java bin中。

代码:

import pandas as pd
import numpy
import tabula
import sys
sys.path.append('E:CommonFilesJavabin')

df = tabula.read_pdf('E:CommonFilesPython-Portable-3.9.6ScriptsSample.pdf', pages='all')

错误消息:

runfile('E:/CommonFiles/Python-Portable-3.9.6/Scripts/untitled01.py', wdir='E:/CommonFiles/Python-Portable-3.9.6/Scripts')
Traceback (most recent call last):
File "E:CommonFilesPython-Portable-3.9.6appslibsite-packagestabulaio.py", line 80, in _run
result = subprocess.run(
File "E:CommonFilesPython-Portable-3.9.6appslibsubprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "E:CommonFilesPython-Portable-3.9.6appslibsite-packagesspyder_kernelscustomizespydercustomize.py", line 108, in __init__
super(SubprocessPopen, self).__init__(*args, **kwargs)
File "E:CommonFilesPython-Portable-3.9.6appslibsubprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "E:CommonFilesPython-Portable-3.9.6appslibsubprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
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 "E:CommonFilesPython-Portable-3.9.6Scriptsuntitled01.py", line 15, in <module>
df = tabula.read_pdf('E:CommonFilesPython-Portable-3.9.6ScriptsSample.pdf', pages='all')
File "E:CommonFilesPython-Portable-3.9.6appslibsite-packagestabulaio.py", line 322, in read_pdf
output = _run(java_options, kwargs, path, encoding)
File "E:CommonFilesPython-Portable-3.9.6appslibsite-packagestabulaio.py", line 91, in _run
raise JavaNotFoundError(JAVA_NOT_FOUND_ERROR)
JavaNotFoundError: `java` command is not found from this Python process.Please ensure Java is installed and PATH is set for `java`

我也尝试过使用camelot,对ghostscript.dll有类似的挫败感。

最后,我查看了pdfplumber,但在那里找到桌子的运气更差,更不用说用它们做任何事情了。

我确信这是可行的,但我的谷歌功能目前让我失望了,我花了3天的时间研究这个问题,但我无法通过谷歌、StackOverflow、Reddit等找到解决方案。

我遇到了同样的问题,我找到的解决方案是使用可移植Java并将其注册到用户环境路径中。这解释了如何从EXE安装程序安装javahttps://stackoverflow.com/a/6571736/11322275然后,将保存java文件夹的位置注册到用户环境路径中,如下所述https://stackoverflow.com/a/67844469/11322275完成上述后,请确保您可以在命令提示符下调用java -version

相关内容

  • 没有找到相关文章

最新更新