我想使用 python 创建一个 Azure 函数应用程序。
在我的应用程序中,我需要将 pdf 转换为图像。
这个需要用到popple-utils。
当我运行应用程序并且想要将 pdf 转换为图像时:convert_from_bytes(file_name,500)
我收到此错误:无法获取页数。 poppler 是否已安装并位于 PATH 中?
我该如何解决这个问题?
最佳答案
我尝试对 Azure 功能进行 dockerize,它完全有效 只需要在项目的根目录中添加广告 Docker 文件,如下所示:
来自 mcr.microsoft.com/azure-functions/python:3.0-python3.7
ENV AzureWebJobsScriptRoot=/home/site/wwwroot\
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
复制requirements.txt/
运行 apt-get update -y
运行 apt-get install poppler-utils -y
运行 pip install -r/requirements.txt
复制 。/home/site/wwwroot
然后对其进行 Docker 化并将其推送到 Azure 注册表。
- 导航到您的 Azure 门户
- 创建 Azure 函数 (docker)
- 导航至部署中心
- 解决您的 docker 镜像
- 它会正常工作
关于python - azure 函数 poppler 实用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69737043/