"module not found" error: "Failure Exception: ImportError: libpq.so.5: cannot open shared object file: No such file or directory. Cannot find module."

问题描述

发布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。

【Azure Function】发布 Python Function 到 Azure 成功,但是无法显示Function列表_Azure

(在 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

 

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!