I published a python 3.10 function app to azure, locally the function runs successfully.
The deployment is successful, but executing the function on cloud, returning the following error:
Result: Failure Exception: ModuleNotFoundError: No module named 'cv2'. Please check the requirements.txt file for the missing module. For more info, please refer the troubleshooting guide: https://aka.ms/functions-modulenotfound Stack: File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/dispatcher.py", line 387, in _handle__function_load_request func = loader.load_function( File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 48, in call raise extend_exception_message(e, message) File "/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 44, in call return func(*args, **kwargs) File "/azure-functions-...
The requirements.txt file exists in the root folder and contains list of all packages including cv
opencv-contrib-python==4.5.5.62
opencv-python==4.5.5.62
(I can see it in Azure portal -> Function App -> App Files)
What am I missing?
2
Answers
The issue was that these two configurations were in the function app.
Removing them enabled the installation of packages specified in the requirements.txt file:
I have created a python 3.10 HTTP triggered function having below code.
Function code–
requirements.txt–
I have debugged my function in vs code and able to get the expected output while executing the function locally.
Post publishing the function to function app, I am also getting successful output.
If requirement.txt file is containing all the modules post deployment then your function should work alike me. If the issue still persists, you can consider deploying the function to a freshly created function app.