python - Azure 函数要求 pdftotext

标签 python azure azure-functions

我的 Azure 函数遇到运行时错误:

Result: Failure Exception: Exception: pdftotext is not installed. It is part of xpdf or poppler-utils software suite. 
Installation on Linux: wget --no-check-certificate https://dl.xpdfreader.com/xpdf-tools-linux-4.02.tar.gz && tar -xvf xpdf-tools-linux-4.02.tar.gz && sudo cp xpdf-tools-linux-4.02/bin64/pdftotext /usr/local/bin 
Installation on MacOS: brew install xpdf 
You can find more details here: https://www.xpdfreader.com 
Stack: File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/dispatcher.py", line 357, in _handle__invocation_request self.__run_sync_func, invocation_id, fi.func, args) File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) 
File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/dispatcher.py", line 542, in __run_sync_func return func(**params) File "/home/site/wwwroot/testFunction/__init__.py", line 45, in main searchResult = bootLoader.run(filePath, query) 
File "/home/site/wwwroot/testFunction/bootLoader.py", line 44, in run doc = docPrepare(filePath) File "/home/site/wwwroot/testFunction/bootLoader.py", line 19, in docPrepare converter = PDFToTextConverter(remove_numeric_tables=True, valid_languages=["en"]) File "/home/site/wwwroot/testFunction/haystack/file_converter/pdf.py", line 38, in __init__ """
Error

由于我在本地安装了 xpdf,因此该函数在我的计算机上成功运行。我的问题是如何将pdftotext安装到我的函数的运行环境(linux)?

ENV

Python 3.6

MAC OSX Mojave

通过 vs code azure 函数扩展部署

更新

我访问了https://{FunctionAppName}.scm.azurewebsites.net/enter image description here

最佳答案

您可以从函数应用程序使用 Kudu 控制台,然后需要导航到 www 根文件夹并执行 pip install

我已经在这个post的最后一节中描述过

关于python - Azure 函数要求 pdftotext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65977860/

相关文章:

Python——输出文件中的数据位于不方便的位置

python - 强制Hive表中的每一行使用一个映射器

sql - 突触顶级父层次结构

python - 如何使用arm模板部署python azure函数?

c# - 使用 SignalR 输出绑定(bind)的 CosmosDB Azure 函数触发器

python - 在 C++ 中嵌入 Python (CPython API)

python - 具有多处理功能的 pyserial 给了我一个 ctype 错误

Azure CLI - 如何在启用软删除和版本控制的情况下恢复删除存储 Blob

azure - Azure 上的西欧云服务在美国展示

c# - 如何从 Function App 指定 Azure Key Vault Secret 的属性?