I am using the package pypandoc for converting DOC/DOCX files into HTML. This has a prerequisite of Pandoc being already installed. When both packages are installed using the requirements.txt
file, it works locally. When I deploy it as an Azure Function, however, it always gives a "module not found" error. (pypandoc cannot find pandoc in the same path because it gets installed elsewhere.)
This seems like a known issue. Pandoc does not get installed in the same path as Pyandoc and there are multiple solutions suggested. But they only locally.
Options tried:
Use pandoc_download
from pypandoc.pandoc_download import download_pandoc
Use wdc. This does not fix the problem.
Use wheel files that include Pandoc.
Right now I am using mammoth for conversion which is slightly lower in accuracy, but gets deployed on Az. How can I get Pypandoc working as an Azure Function? How can I install Pandoc in a place where Pypandoc can find it? Or, how can I tell Pypandoc where to find Pandoc?
I test it in my side, I install
pandoc
andpypandoc
in local by the commandpip install pypandoc
andpip install pandoc
but not install them usingrequirements.txt
. The function works fine in local.And then I generate the
requirements.txt
by running the commandpip freeze > requirements.txt
. Then deploy the function to azure by running the commandfunc azure functionapp publish <your function app name> --build remote
, azure will install the modules according the content ofrequirements.txt
. After the deployment, the function run success on azure portal.