Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
333 stars 103 forks source link

[BUG] No module named 'requests' after switching to python 3.7 #1224

Closed susanhuhu closed 1 year ago

susanhuhu commented 1 year ago

This app used to work well when I used python 3.6. However, I had to switch to python 3.7 for some other reason. I got below error after that Failure\nException: ModuleNotFoundError: No module named 'requests'. Troubleshooting Guide: https://aka.ms/functions-modulenotfound\nStack: File \"/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/dispatcher.py\", line 318, in _handlefunction_load_request\n func_request.metadata.entry_point)\n File \"/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/utils/wrappers.py\", line 42, in call\n raise extend_exception_message(e, message)\n File \"/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/utils/wrappers.py\", line 40, in call\n return func(*args, **kwargs)\n File \"/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/loader.py\", line 85, in load_function\n mod = importlib.import_module(fullmodname)\n File \"/usr/local/lib/python3.7/importlib/init__.py\", line 127, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n File \"/home/site/wwwroot/get_roles/init.py\", line 7, in \n import requests\n","type":"Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException","id":"40697897",

I used below command "az functionapp config set --linux-fx-version 'Python"|"3.7' -n jadhuang-incident-mitigation-functions -g groupname"

Below is my requirements file. azure-functions==1.11.2 azure-functions-durable==1.1.6 pyodbc==4.0.35 mock pandas pytest

I checked the package that is deployed to the function app, I do see worker_venv\lib\python3.7\site-packages\requests have content. I am a Microsoft employee so if there is a way I can share you the build pipeline and deploy pipeline please let me know.

I also tried manually deploy with cli command az functionapp deployment source config-zip -n jadhuang-incident-mitigation-functions -g xxx --src "c:\users\xx\Downloads\20775.zip" and issue doesn't go away

bhagyshricompany commented 1 year ago

Thanks for informing will check and update you

bhagyshricompany commented 1 year ago

seems working fine as I tried in windows .can you try again and specify the more issue on this.

susanhuhu commented 1 year ago

Mine is on Linux Ubuntu, I believe the OS is Ubuntu 18.04

susanhuhu commented 1 year ago

If I provide subscription, resource group and resource name, does that help you find out what happend to this Azure Function instance?

bhagyshricompany commented 1 year ago

yes pls share

bhagyshricompany commented 1 year ago

pls share function app name region,instance/invocation id ,plan.

susanhuhu commented 1 year ago

this is fixed. it turns out work_venv folder is not supported anymore.