问题描述
发布Python Function到Azure Function App服务,发布成功后,在Overview页面却无法查看到这个Function,进入Kudu站点,查看Function Log,发现错误信息为:
"module not found" error: "Failure Exception: ImportError: libpq.so.5: cannot open shared object file: No such file or directory. Cannot find module."
问题解答
经过调查,在网上发现相同的错误信息。 原因是无法加载psycopg2模块,需要使用 psycopg2-binary。
(在 requirements.txt 中,使用 psycopg2-binary )
根据文档提示修改后,Function显示并执行成功!
参考资料
Unable to get Azure Function Python 3.8 to work in Azure #1586: https://github.com/Azure/Azure-Functions/issues/1586
python function app works locally but not when deployed :https://learn.microsoft.com/en-us/answers/questions/174155/python-function-app-works-locally-but-not-when-dep