azure-functions-python-worker
azure-functions-python-worker copied to clipboard
ModuleNotFoundError: No module named 'aiohttp'
I'm trying to host a sample python bot using Azure app services.
https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/python/02.echo-bot
Im getting below error while app startup.
2020-07-03T10:50:27.628634000Z ModuleNotFoundError: No module named 'aiohttp' 2020-07-03T10:50:27.636552057Z [2020-07-03 10:50:27 +0000] [39] [INFO] Worker exiting (pid: 39) 2020-07-03T10:50:27.708003675Z [2020-07-03 10:50:27 +0000] [37] [INFO] Shutting down: Master 2020-07-03T10:50:27.708706180Z [2020-07-03 10:50:27 +0000] [37] [INFO] Reason: Worker failed to boot.
I have aiohttp installed on the container.
/home/site/wwwroot>pip install aiohttp Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: aiohttp in /home/.local/lib/python3.8/site-packages (3.6.2) Requirement already satisfied: attrs>=17.3.0 in /home/.local/lib/python3.8/site-packages (from aiohttp) (19.3.0) Requirement already satisfied: multidict<5.0,>=4.5 in /home/.local/lib/python3.8/site-packages (from aiohttp) (4.7.6) Requirement already satisfied: chardet<4.0,>=2.0 in /home/.local/lib/python3.8/site-packages (from aiohttp) (3.0.4) Requirement already satisfied: yarl<2.0,>=1.0 in /home/.local/lib/python3.8/site-packages (from aiohttp) (1.4.2) Requirement already satisfied: async-timeout<4.0,>=3.0 in /home/.local/lib/python3.8/site-packages (from aiohttp) (3.0.1) Requirement already satisfied: idna>=2.0 in /home/.local/lib/python3.8/site-packages (from yarl<2.0,>=1.0->aiohttp) (2.8) Cleaning up.
Any help on this would be really appreciated!
Hi @neethumoltp, I think in your case, instead of hosting your application on Azure Functions, you should find instruction of hosting Python apps on App Service, since Azure Functions required specific folder structure for our platform to recognize.
Please follow the instruction here https://docs.microsoft.com/en-us/azure/app-service/containers/quickstart-python?tabs=bash and let me know if you have any questions.
Im able to host a "hello world " app in azure using Azure app services.
But not able to host any bot having aiohttp module. For eg, https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/python/02.echo-bot
Any further updates on this?
@neethumoltp What errors are you seeing when running the app in App service?
Hi, Initially I was getting ModuleNotFoundError: No module named 'aiohttp' error (for more errors please check the description of the issue). aiohttp module is not getting deployed even though its part of requirement.txt
I have added "pip install aiohttp" as a startup command to fix this.
However now container is failing on the startup.
2020-07-20T12:28:00.699Z INFO - Initiating warmup request to container daq3_0_405e8e5a for site daq3 2020-07-20T12:28:08.101Z ERROR - Container daq3_0_405e8e5a for site daq3 has exited, failing site start 2020-07-20T12:28:08.108Z ERROR - Container daq3_0_405e8e5a didn't respond to HTTP pings on port: 3978, failing site start. See container logs for debugging. 2020-07-20T12:28:08.123Z INFO - Stopping site daq3 because it failed during startup.
I found the following exception but haven't investigated what this means.
Container daq3_0_0adbda65 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
Pasting this here since it might give you a clue as to what is failing.
Same error for me too. Deployment keeps on failing on one after another
@Hazhzeng @msftbot Hi... did you solved this error for you? if yes, how did you solve that error? actually, I am facing the same error. I have also added "aiohttp" in my "requirements.txt" but still it is giving same error.
can anyone help me with this?
Hello!, any updates on this?. Thanks.
I got the same error and decided to deploy the bot via VS Code - App Service to investigate the issue. Deployment was successful with a warning that I have a higher version of 'requests' package which is not compatible with aiohttp that requires requests==2.23.0. Adding requests==2.23.0 to my requirements.txt solved the issue. Hope it helps!:)
Same issue, @MedvidekPu , where can we see the compatible list ? I'm running into python 3.7 version in azure app service, the below is my requriements.txt file
botbuilder_schema==4.13.0
requests==2.25.0
aiohttp==3.7.4
botbuilder==0.0.1
botbuilder-core==4.13.0
botbuilder-dialogs==4.13.0
Giving ModuleNotFoundError: No module named 'aiohttp'
@Hazhzeng any workaround /fix for this to unblock us ?
@jayendranarumugam I am not sure if it is the best way, but what helped me was to deploy the bot into App serivce via VS Code as suggested here: https://microsoftlearning.github.io/AI-102-AIEngineer/Instructions/13-bot-framework.html
If you deploy your app in VS Code extension Azure App Service using the button "Deploy to web app" instead of Azure CLI deployment, you will get a small Output window where all warnings and errors should be displayed to help you understand what packages are not compatible. Once the deployment was without warnings I then proceeded normally with the deployment through Azure CLI.
Thanks @MedvidekPu I finally able to solve my issue and shared in this SO which as follows
-
By default Kudu assumes that zip deployments do not require any build-related actions like
npm install
ordotnet publish
. So the cause in this case might bepip installation
did not been taken care properly.To make it install all required packages in requirements.txt file automatically, we can simply set
SCM_DO_BUILD_DURING_DEPLOYMENT
totrue
in appsettings, then deploy again. -
Need to setup the startup command like
gunicorn --bind 0.0.0.0 --worker-class aiohttp.worker.GunicornWebWorker --timeout 600 app:APP
-
Configure the
MicrosoftAppId
andMicrosoftAppPassword
properly
I've followed @jayendranarumugam 's solution but I still have the problem.
I have .deployment
file:
[config]
SCM_DO_BUILD_DURING_DEPLOYMENT = true
I'm deploying my folder like this:
az webapp deployment source config-zip --resource-group "<resource_name>" --name "<service_name>" --src "echo-bot.zip"
I get the following logs on the service:
2024-02-15T15:57:26.483Z INFO - Starting container for site
2024-02-15T15:57:26.491Z INFO - docker run -d --expose=8000 --name alma-service_0_8d21d1bf -e WEBSITE_USE_DIAGNOSTIC_SERVER=false -e WEBSITE_CORS_ALLOWED_ORIGINS=https://botservice.hosting.portal.azure.net,https://hosting.onecloud.azure-test.net/ -e WEBSITE_CORS_SUPPORT_CREDENTIALS=False -e WEBSITE_SITE_NAME=alma-service -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=alma-service.azurewebsites.net -e WEBSITE_INSTANCE_ID=fca8f86e2aee5216a9504a5ef5a82caeab7a80b1093c88842a262c639a933047 -e HTTP_LOGGING_ENABLED=1 appsvc/python:3.7-bullseye_20230810.1.tuxprod gunicorn --bind 0.0.0.0 --worker-class aiohttp.worker.GunicornWebWorker --timeout 600 app:APP
SITE_CORS_SUPPORT_CREDENTIALS=False -e WEBSITE_SITE_NAME=alma-service -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=alma-service.azurewebsites.net -e WEBSITE_INSTANCE_ID=fca8f86e2aee5216a9504a5ef5a82caeab7a80b1093c88842a262c639a933047 -e HTTP_LOGGING_ENABLED=1 mcr.microsoft.com/appsvc/middleware:stage5 /Host.ListenUrl=http://0.0.0.0:8181 /Host.DestinationHostUrl=http://169.254.130.2:8000 /Host.UseFileLogging=true
2024-02-15T15:43:46.670426110Z _____
2024-02-15T15:43:46.670497510Z / _ \ __________ _________ ____
2024-02-15T15:43:46.670504310Z / /_\ \\___ / | \_ __ \_/ __ \
2024-02-15T15:43:46.670508010Z / | \/ /| | /| | \/\ ___/
2024-02-15T15:43:46.670511110Z \____|__ /_____ \____/ |__| \___ >
2024-02-15T15:43:46.670514310Z \/ \/ \/
2024-02-15T15:43:46.670517410Z A P P S E R V I C E O N L I N U X
2024-02-15T15:43:46.670520210Z
2024-02-15T15:43:46.670522810Z Documentation: http://aka.ms/webapp-linux
2024-02-15T15:43:46.670525610Z Python 3.7.17
2024-02-15T15:43:46.670528310Z Note: Any data outside '/home' is not persisted
2024-02-15T15:43:48.090492044Z Starting OpenBSD Secure Shell server: sshd.
2024-02-15T15:43:48.297599217Z Site's appCommandLine: gunicorn --bind 0.0.0.0 --worker-class aiohttp.worker.GunicornWebWorker --timeout 600 app:APP
2024-02-15T15:43:48.323954549Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -userStartupCommand 'gunicorn --bind 0.0.0.0 --worker-class aiohttp.worker.GunicornWebWorker --timeout 600 app:APP'
2024-02-15T15:43:48.569412680Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2024-02-15T15:43:48.582016743Z Build Operation ID: cdc039210da64e13
2024-02-15T15:43:48.600154834Z Output is compressed. Extracting it...
2024-02-15T15:43:48.600201434Z Oryx Version: 0.2.20230707.1, Commit: 0bd28e69919b5e8beba451e8677e3345f0be8361, ReleaseTagName: 20230707.1
2024-02-15T15:43:48.607437270Z Extracting '/home/site/wwwroot/output.tar.gz' to directory '/tmp/8dc2e3cb11ade62'...
2024-02-15T15:43:51.966293014Z App path is set to '/tmp/8dc2e3cb11ade62'
2024-02-15T15:43:52.884927521Z Writing output script to '/opt/startup/startup.sh'
2024-02-15T15:43:53.398150895Z Using packages from virtual environment antenv located at /tmp/8dc2e3cb11ade62/antenv.
2024-02-15T15:43:53.398191696Z Updated PYTHONPATH to '/opt/startup/app_logs:/tmp/8dc2e3cb11ade62/antenv/lib/python3.7/site-packages'
2024-02-15T15:43:56.986516383Z
2024-02-15T15:43:56.986573883Z Error: class uri 'aiohttp.worker.GunicornWebWorker' invalid or not found:
2024-02-15T15:43:56.986580183Z
2024-02-15T15:43:56.986583683Z [Traceback (most recent call last):
2024-02-15T15:43:56.986587083Z File "/opt/python/3.7.17/lib/python3.7/site-packages/gunicorn/util.py", line 99, in load_class
2024-02-15T15:43:56.986590783Z mod = importlib.import_module('.'.join(components))
2024-02-15T15:43:56.986594183Z File "/opt/python/3.7.17/lib/python3.7/importlib/__init__.py", line 127, in import_module
2024-02-15T15:43:56.986598283Z return _bootstrap._gcd_import(name[level:], package, level)
2024-02-15T15:43:56.986601583Z File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
2024-02-15T15:43:56.986618684Z File "<frozen importlib._bootstrap>", line 983, in _find_and_load
2024-02-15T15:43:56.986622684Z File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
2024-02-15T15:43:56.986625984Z File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2024-02-15T15:43:56.986629384Z File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
2024-02-15T15:43:56.986632684Z File "<frozen importlib._bootstrap>", line 983, in _find_and_load
2024-02-15T15:43:56.986635984Z File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
2024-02-15T15:43:56.986639384Z ModuleNotFoundError: No module named 'aiohttp'
2024-02-15T15:43:56.986642684Z ]
2024-02-15T15:43:56.986645784Z
te alma-service initialized successfully and is ready to serve requests.
2024-02-15T15:44:02.414Z ERROR - Container alma-service_0_7564f659 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2024-02-15T15:44:02.451Z INFO - Stopping site alma-service because it failed during startup.
I don't think pip install -r requirements.txt
is being run. How can I force it to run that?