botbuilder-python icon indicating copy to clipboard operation
botbuilder-python copied to clipboard

Can't deploy echo-bot.py. ModuleNotFoundError: No module named 'aiohttp'

Open jpiabrantes opened this issue 1 year ago • 1 comments

Versions

Here's my requirements.txt
botbuilder_schema==4.13.0
gunicorn==20.1.0
aiohttp==3.6.3
botbuilder-integration-aiohttp==4.13.0
botbuilder-ai==4.13.0
botbuilder==0.0.1
botbuilder-core==4.13.0
botbuilder-dialogs==4.13.0

Describe the bug

Here's the error message
2024-02-15T14:28:44.906911470Z    _____                               
2024-02-15T14:28:44.906996971Z   /  _  \ __________ _________   ____  
2024-02-15T14:28:44.907002071Z  /  /_\  \\___   /  |  \_  __ \_/ __ \ 
2024-02-15T14:28:44.907005571Z /    |    \/    /|  |  /|  | \/\  ___/ 
2024-02-15T14:28:44.907008971Z \____|__  /_____ \____/ |__|    \___  >
2024-02-15T14:28:44.907012571Z         \/      \/                  \/ 
2024-02-15T14:28:44.907015771Z A P P   S E R V I C E   O N   L I N U X
2024-02-15T14:28:44.907019271Z 
2024-02-15T14:28:44.907022471Z Documentation: http://aka.ms/webapp-linux
2024-02-15T14:28:44.907025671Z Python 3.7.17
2024-02-15T14:28:44.907028771Z Note: Any data outside '/home' is not persisted
2024-02-15T14:28:47.919246257Z Starting OpenBSD Secure Shell server: sshd.
2024-02-15T14:28:48.126441484Z Site's appCommandLine: gunicorn --bind 0.0.0.0 --worker-class aiohttp.worker.GunicornWebWorker --timeout 600 app:APP
2024-02-15T14:28:48.126477484Z 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-15T14:28:48.187623605Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2024-02-15T14:28:48.187668106Z Build Operation ID: 1014dbc4d99e9853
2024-02-15T14:28:48.197276572Z Output is compressed. Extracting it...
2024-02-15T14:28:48.205194026Z Extracting '/home/site/wwwroot/output.tar.gz' to directory '/tmp/8dc2e31979c41aa'...
2024-02-15T14:28:48.197713275Z Oryx Version: 0.2.20230707.1, Commit: 0bd28e69919b5e8beba451e8677e3345f0be8361, ReleaseTagName: 20230707.1
2024-02-15T14:28:50.351728409Z App path is set to '/tmp/8dc2e31979c41aa'
2024-02-15T14:28:51.165217213Z Writing output script to '/opt/startup/startup.sh'
2024-02-15T14:28:51.425979509Z Using packages from virtual environment antenv located at /tmp/8dc2e31979c41aa/antenv.
2024-02-15T14:28:51.449039868Z Updated PYTHONPATH to '/opt/startup/app_logs:/tmp/8dc2e31979c41aa/antenv/lib/python3.7/site-packages'
2024-02-15T14:28:55.296754676Z 
2024-02-15T14:28:55.296796276Z Error: class uri 'aiohttp.worker.GunicornWebWorker' invalid or not found: 
2024-02-15T14:28:55.296803276Z 
2024-02-15T14:28:55.296807276Z [Traceback (most recent call last):
2024-02-15T14:28:55.296811176Z   File "/opt/python/3.7.17/lib/python3.7/site-packages/gunicorn/util.py", line 99, in load_class
2024-02-15T14:28:55.296815276Z     mod = importlib.import_module('.'.join(components))
2024-02-15T14:28:55.296819076Z   File "/opt/python/3.7.17/lib/python3.7/importlib/__init__.py", line 127, in import_module
2024-02-15T14:28:55.296822976Z     return _bootstrap._gcd_import(name[level:], package, level)
2024-02-15T14:28:55.296826776Z   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
2024-02-15T14:28:55.296840176Z   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
2024-02-15T14:28:55.296844176Z   File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
2024-02-15T14:28:55.296847976Z   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2024-02-15T14:28:55.296851776Z   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
2024-02-15T14:28:55.296859076Z   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
2024-02-15T14:28:55.296862676Z   File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
2024-02-15T14:28:55.296866477Z ModuleNotFoundError: No module named 'aiohttp'
2024-02-15T14:28:55.296869977Z ]

To Reproduce

I am following the official documentation on how to deploy the echo-bot.py.

I use this command to deploy the bot: az webapp deployment source config-zip --resource-group "resource_name" --name "service_name" --src "echo-bot.zip"

Here are the contents of my zip's root folder
- README.md
- __init__.py
- app.py
- bot.py
- config.py
- deploymentTemplates
- requirements.txt
- .deployment
- .env

Additional context

I have looked at these posts but they didn't help.

jpiabrantes avatar Feb 15 '24 16:02 jpiabrantes

I was looking for a solution to the same error ModuleNotFoundError: No module named 'aiohttp', but in my case, I discovered that there were some conflicting dependencies in my requirements.txt file.

So, my process was:

I started from scratch using the EchoBot from Microsoft Learn Create a bot with the Bot Framework SDK. Then, I created my Azure Web App, adding the Start Command and the environment variables as stated in the post that you mentioned: ModuleNotFoundError: No module named 'aiohttp'

After that, I ran az webapp up to deploy my code and it worked perfectly! :open_mouth:

In the end, I just had to remove various dependencies from my requirements.txt file and I only used 'botbuilder-integration-aiohttp>=4.14.0' for the Basic EchoBot.

I hope this could help you.

ing-jorgehv avatar Feb 23 '24 19:02 ing-jorgehv

We recently discovered the linked document above. Unclear why that exists as the one we typically provide, and has been updated more often is: https://learn.microsoft.com/en-us/azure/bot-service/provision-and-publish-a-bot?view=azure-bot-service-4.0&tabs=userassigned%2Ccsharp

tracyboehrer avatar Mar 19 '24 14:03 tracyboehrer

I was looking for a solution to the same error ModuleNotFoundError: No module named 'aiohttp', but in my case, I discovered that there were some conflicting dependencies in my requirements.txt file.

So, my process was:

I started from scratch using the EchoBot from Microsoft Learn Create a bot with the Bot Framework SDK. Then, I created my Azure Web App, adding the Start Command and the environment variables as stated in the post that you mentioned: ModuleNotFoundError: No module named 'aiohttp'

After that, I ran az webapp up to deploy my code and it worked perfectly! 😮

In the end, I just had to remove various dependencies from my requirements.txt file and I only used 'botbuilder-integration-aiohttp>=4.14.0' for the Basic EchoBot.

I hope this could help you.

It solved my problem! Thank you 🦙

rodrigo-br avatar Apr 18 '24 19:04 rodrigo-br

I can confirm this is what worked for me as well, would be nice if the echo bot docs where updated accordingly, what's strange is that if I install

botbuilder-core>=4.7.0
aiohttp==3.10.3

locally, the bot runs fine # smh

ndamulelonemakh avatar Aug 13 '24 01:08 ndamulelonemakh

What version of Python are you using? Somewhere along the way aiohttp dropped support for older versions. Azure is using later versions.

tracyboehrer avatar Aug 13 '24 13:08 tracyboehrer

Python 3.7 support was lost in BF SDK version 4.15.0: https://github.com/microsoft/botbuilder-python/releases/tag/4.15.0

Verify the Azure App Service deployment is using 3.8+

tracyboehrer avatar Aug 13 '24 13:08 tracyboehrer