python-pptx icon indicating copy to clipboard operation
python-pptx copied to clipboard

python pptx in Docker container error

Open FPRM opened this issue 2 years ago • 2 comments

config: OS:

  • NAME="Debian GNU/Linux"
  • VERSION_ID="11"
  • VERSION="11 (bullseye)"

Python:

  • 3.7.13 python-pptx :

  • python-pptx==0.6.21

I'm trying to embed a python pptx process into a docker container for AWS lambda execution as API to fill blank templates. When executing the process on my local computer (windows 10 ) everything works fine.

But when building and executing it into a Docker container it raise following error.

the docker console prints out following error

18 Mar 2022 09:26:52,340 [INFO] (rapid) exec '/usr/local/bin/python' (cwd=/function, handler=app.handler)
18 Mar 2022 09:27:14,485 [INFO] (rapid) extensionsDisabledByLayer(/opt/disable-extensions-jwigqn8j) -> stat /opt/disable-extensions-jwigqn8j: no such file or directory
18 Mar 2022 09:27:14,488 [WARNING] (rapid) Cannot list external agents error=open /opt/extensions: no such file or directory
START RequestId: ecb716fa-71a9-4db1-a2b5-3c780fe06f41 Version: $LATEST
    raise OSError("unsupported operating system")n _font_directoriesze
END RequestId: ecb716fa-71a9-4db1-a2b5-3c780fe06f41

And the API request error output following.

{
  "errorMessage": "unsupported operating system",
  "errorType": "OSError",
  "requestId": "ecb716fa-71a9-4db1-a2b5-3c780fe06f41",
  "stackTrace": [
    "  File \"/function/app.py\", line 14, in handler\n    output = fiche_pde()\n",
    "  File \"/function/function.py\", line 55, in fiche_pde\n    tf.fit_text()\n",
    "  File \"/function/pptx/text/text.py\", line 85, in fit_text\n    font_family, max_size, bold, italic, font_file\n",
    "  File \"/function/pptx/text/text.py\", line 238, in _best_fit_font_size\n    font_file = FontFiles.find(family, bold, italic)\n",
    "  File \"/function/pptx/text/fonts.py\", line 27, in find\n    cls._font_files = cls._installed_fonts()\n",
    "  File \"/function/pptx/text/fonts.py\", line 38, in _installed_fonts\n    for d in cls._font_directories():\n",
    "  File \"/function/pptx/text/fonts.py\", line 53, in _font_directories\n    raise OSError(\"unsupported operating system\")\n"
  ]
}

FPRM avatar Mar 18 '22 09:03 FPRM