I cant load any python modules in azure web apps

jesuspp12 1 Reputation point
2020-11-02T23:38:10.057+00:00

Hello,
I am trying to make a flask server in web apps, but when I run the app, it gives an error that there is no module named requests (A module that I want to use).
Already tried to install via the requirements.txt in my app setup, but it keeps giving the same problem.
some prints:
36879-error.png

requirements:
36925-image.png

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. UD 11 Reputation points
    2020-11-09T19:31:29.217+00:00

    By default, python web apps don’t build/installs requirements.txt packages. You explicitly need to add

    SCM_DO_BUILD_DURING_DEPLOYMENT = true

    in web app’s configuration settings.
    This will force your app to build every time a new code is deployed.
    Hope this helps...

    2 people found this answer helpful.

  2. ajkuma 28,036 Reputation points Microsoft Employee Moderator
    2020-11-03T11:16:25.567+00:00

    @jesuspp12 ,

    I understand you have already reviewed the requirement.txt file, kindly confirm if the file path is correct.

    Use SSH or the Kudu console to connect directly to the App Service and verify that requirements.txt exists directly under site/wwwroot. If it doesn't exist, make site the file exists in your repository and is included in your deployment. If it exists in a separate folder, move it to the root. If your files exist, then App Service wasn't able to identify your specific startup file. Check that your app is structured as App Service expects for Flask, or use a custom startup command.

    For Flask, App Service looks for a file named application.py or app.py and starts Gunicorn as follows:

    # If application.py -->     gunicorn --bind=0.0.0.0 --timeout 600 application:app  
    # If app.py --> gunicorn --bind=0.0.0.0 --timeout 600 app:app  
    

Your answer

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