/opt/python/3.11.14/bin/python: No module named uvicorn

shogga 0 Reputation points
2025-12-16T15:04:58.0833333+00:00

Dear Experts,
My first post regarding my attempt as a learner/hobbyist to deploy my app. Currently getting the following

/opt/python/3.11.14/bin/python: No module named uvicorn

when I execute

 az webapp deploy -g heatpump_group-aefb -n heatpump --type zip --src-path .\deploy.zip

I have checked my deploy.zip and inside this we have the requirements.txt with

uvicorn>=0.37.0

Any ideas what may be the problem?

BR

Shogga

Azure App Service
Azure App Service

Azure App Service is a service used to create and deploy scalable, mission-critical web apps.

0 comments No comments

2 answers

Sort by: Most helpful
  1. shogga 0 Reputation points
    2025-12-17T10:44:54.6233333+00:00

    Thanks for the troubleshooting suggestions! I confirm the following:

    • requirements.txt at deployment zip root
    • SCM_DO_BUILD_DURING_DEPLOYMENT set to 1
    • Python 3.11.14 runtime working correctly
    • Startup command: python -m uvicorn research_agent_ai_assist:app --host 0.0.0.0 --port 8000
    • Log stream shows successful Oryx build start

    As a test, when I reduce to <10 essential dependencies in requirements.txt, uvicorn gets installed

    Collecting uvicorn... Successfully installed h11-0.16.0 uvicorn-0.38.0
    
    

    If I load the full 68+ dependencies (LangChain, pandas, matplotlib, scikit-learn, chromadb, spacy, etc.) in requirements, I think the Oryx build process times out during pip install on Free Tier but I am not sure...

    Is my Free Tier F1 simply insufficient for scientific/ML apps with large dependency sets, or are there strategies to handle 60+ packages within the resource limits?

    Thanks

    Was this answer helpful?


  2. Anonymous
    2025-12-16T22:01:31.1+00:00

    Hi Shogga

    It looks like you're running into a module not found error for uvicorn when trying to deploy your app to Azure. Here are a few things you can check to resolve this issue:

    1. Verify requirements.txt: Make sure that your requirements.txt file in the deployment package is named correctly and contains the line for uvicorn as you specified: uvicorn>=0.37.0. It's important that the file is at the root of your zip file.
    2. Build during Deployment: You might want to ensure that the Azure environment installs the required packages during deployment. You can do this by setting an app setting in your Azure App Service to SCM_DO_BUILD_DURING_DEPLOYMENT and setting its value to 1. This allows Azure's Oryx build engine to install the required packages as part of the deployment process.
    3. Custom Startup Command: If you are trying to run your app using uvicorn, make sure your startup command in the Azure portal is set correctly. You should use something like: python -m uvicorn application:app --host 0.0.0.0
    4. This command is needed because modules installed via requirements.txt may not be found in the global Python environment without this prefix.
    5. Log Inspection: Check the log stream for any errors related to the deployment. You can access the log stream through the Azure portal, which can provide more insight into what's failing.
    6. Python Environment: Make sure your app is using the correct version of Python compatible with your dependencies. Sometimes, environment mismatches can lead to ModuleNotFoundError.

    If you've checked all these things and are still facing issues, here are a few follow-up questions that could help diagnose the problem further:

    • Can you confirm that your requirements.txt is at the root of your deployment zip file?
    • Have you set the app setting SCM_DO_BUILD_DURING_DEPLOYMENT to 1?
    • What version of Python are you running in your Azure App Service?
    • Can you access the log stream and share any relevant error messages?

    I hope this helps! Let me know if you have any other questions.

    References:

    Troubleshooting Azure App Service on Linux

    Configure your Python app for Azure App Service

    Configure a custom startup file for Python apps on Azure App Service

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.