azure-functions-python-worker
azure-functions-python-worker copied to clipboard
Azure function gives Exception: ModuleNotFoundError: No module named 'XXXXXXXX'. Cannot find module.
Azure FUnction Essentials - Operating System: Linux Runtime version: 4.31.1.1
Question
I have been working with Azure functions for a while, and they have been working as expected so far. However, all the recent Azure Functions that I have built and deployed are giving module not found error on the imported python modules even though they have been included in the requirements.txt file. We can clearly see that the modules get installed in GitHub build and deployment, but the Azure Function log stream shows
"Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException: Result: Failure
Exception: ModuleNotFoundError: No module named 'pandas'. Cannot find module. Please check the requirements.txt file for the missing module.
For more info, please refer the troubleshooting guide: https://aka.ms/functions-modulenotfound. Current sys.path: ['/home/site/wwwroot', '/home/site/wwwroot/.python_packages/lib/site-packages', '/azure-functions-host/workers/python/3.10/LINUX/X64', '/usr/local/lib/python310.zip', '/usr/local/lib/python3.10', '/usr/local/lib/python3.10/lib-dynload', '/usr/local/lib/python3.10/site-packages']"
I have been investigating this issue for a couple of days now. I went through the documentation for troubleshooting and previous GitHub threads discussing this or other similar issues. At first the issue seemed to be only with "pyodbc" module but on further investigation we found that it is an error on Azure side and not on Python. Similar kind of issues were found before where Azure Functions failed with Python and they were swiftly resolved in later versions.
We have tried:
- Rebuilding and redeploying the functions
- Using alternative modules
- Downgrading the python modules to previous stable versions (as suggested in some of the solutions) but to no avail.
I would really appreciate if anyone could give me some inputs. @asavaritayal @ankitkumarr