How to resolve issue with Azure Web App deployment not recognizing requirements.txt?

Tyler Suard 55 Reputation points
2024-03-26T20:47:11.9133333+00:00

I am using this repo: https://github.com/Azure-Samples/msdocs-python-flask-webapp-quickstart

The repo includes a requirements.txt. I added an extra package to requirements.txt, pymongo.

When I deploy my app to a WebApp using the Azure extension in VSCode, the deployment fails, because pymongo was not installed.

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
761 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 15,171 Reputation points Microsoft Employee
    2024-03-26T23:16:11.78+00:00

    @Tyler Suard

    1. Make sure that the requirements.txt file is in the root directory of your project. If it is not in the root directory, the deployment process may not be able to find it.
    2. Check that the requirements.txt file is properly formatted. Each package should be listed on a separate line, and the package name and version should be separated by ==. For example:
         flask==1.1.2
         pymongo==3.11.3
         
      
    3. Check that the pymongo package is spelled correctly in the requirements.txt file. If there is a typo in the package name, the deployment process will not be able to find it.
    4. If you have made changes to the requirements.txt file after the initial deployment, make sure to redeploy the app. The deployment process will only install the packages listed in the requirements.txt file at the time of deployment.
    5. If none of the above steps work, you can try manually installing the pymongo package on the Azure Web App. To do this, you can SSH into the Web App and run the following command:
         pip install pymongo
         
      
      This will install the pymongo package on the Web App, and your app should be able to use it.

    If the above suggestions do not work, reply to this message so we can assist you further.

    0 comments No comments