title: Python version mismatch for Azure Web App
body: <p>I have created a web app on Microsoft Azure and choosen Python 3.8 as configuration.</p>
  <p>Then I set up a deployment pipeline on Azure DevOps which deploys a django app into the web app. The deployment itself also runs fine, artifacts are copied and unzipped. But the installation of the requirements is giving me a hard time.</p>
  <p>On the Configuration section for the Web App on Azure portal I defined &quot;Python 3.8&quot; in the general settings. And in the Azure DevOps pipeline the deployment task is configured to use &quot;PYTHON|3.8&quot; as runtime stack.</p>
  <p>But still the post deployment actions do fail - and this as it looks like is caused by the Kundu component which executes the task and itself is running python 3.5 (python3) and python 2.7 (python).</p>
  <p>The pip installation for django 3.1.4 then fails with error and I am getting warnings about end of life python 3.5.</p>
  <p>Here's deployment step and full output of it</p>
  <pre><code>#Your build pipeline references an undefined variable named ‘Parameters.ConnectedServiceName’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
  #Your build pipeline references an undefined variable named ‘Parameters.WebAppKind’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
  #Your build pipeline references an undefined variable named ‘Parameters.WebAppName’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
  #Your build pipeline references an undefined variable named ‘Parameters.StartupCommand’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
  #Your build pipeline references an undefined variable named ‘Parameters.PythonAppFramework’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
  
  steps:
  - task: AzureRmWebAppDeployment@4
    displayName: 'Deploy Azure App Service'
    inputs:
      azureSubscription: '$(Parameters.ConnectedServiceName)'
      appType: '$(Parameters.WebAppKind)'
      WebAppName: '$(Parameters.WebAppName)'
      packageForLinux: '$(System.DefaultWorkingDirectory)/_xxx-CI/drop/xxx**.zip'
      RuntimeStack: 'PYTHON|3.8'
      StartupCommand: '$(Parameters.StartupCommand)'
      ScriptType: 'Inline Script'
      InlineScript: |
       echo &quot;Printing version of python3&quot;
       python3 --version
       echo &quot;Upgrading pip&quot;
       /usr/bin/python3 -m pip install --upgrade pip
       echo &quot;Installing requirements&quot;
       /usr/bin/python3 -m pip install -r xxx/requirements.txt
      WebConfigParameters: '$(Parameters.PythonAppFramework)'
  </code></pre>
  <pre><code>2020-12-26T14:52:34.2216420Z ##[section]Starting: Deploy Azure App Service
  2020-12-26T14:52:34.2227205Z ==============================================================================
  2020-12-26T14:52:34.2227775Z Task         : Azure App Service deploy
  2020-12-26T14:52:34.2228172Z Description  : Deploy to Azure App Service a web, mobile, or API app using Docker, Java, .NET, .NET Core, Node.js, PHP, Python, or Ruby
  2020-12-26T14:52:34.2228532Z Version      : 4.179.0
  2020-12-26T14:52:34.2228747Z Author       : Microsoft Corporation
  2020-12-26T14:52:34.2229021Z Help         : https://aka.ms/azureappservicetroubleshooting
  2020-12-26T14:52:34.2229517Z ==============================================================================
  2020-12-26T14:52:35.2840047Z Got service connection details for Azure App Service:'xxx-dev'
  2020-12-26T14:53:22.4215194Z Package deployment using ZIP Deploy initiated.
  2020-12-26T14:54:12.3861589Z Deploy logs can be viewed at https://xxx-dev.scm.azurewebsites.net/api/deployments/b87f0b8e9bee48e6a823e1ef681812dd/log
  2020-12-26T14:54:12.3866079Z Successfully deployed web package to App Service.
  2020-12-26T14:54:13.3092961Z Trying to update App Service Application settings. Data: {&quot;SCM_COMMAND_IDLE_TIMEOUT&quot;:&quot;1800&quot;}
  2020-12-26T14:54:13.3105380Z App Service Application settings are already present.
  2020-12-26T14:54:13.5984663Z Executing given script on Kudu service.
  2020-12-26T14:54:33.9532357Z Standard output from script: 
  2020-12-26T14:54:33.9534448Z Printing version of python3
  2020-12-26T14:54:33.9534739Z Python 3.5.3
  2020-12-26T14:54:33.9534967Z Upgrading pip
  2020-12-26T14:54:33.9535578Z Defaulting to user installation because normal site-packages is not writeable
  2020-12-26T14:54:33.9536860Z Requirement already satisfied: pip in /home/.local/lib/python3.5/site-packages (20.3.3)
  2020-12-26T14:54:33.9537372Z Installing requirements
  2020-12-26T14:54:33.9537892Z Defaulting to user installation because normal site-packages is not writeable
  2020-12-26T14:54:33.9538291Z Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
  2020-12-26T14:54:33.9538602Z 
  2020-12-26T14:54:33.9544250Z Standard error from script: 
  2020-12-26T14:54:33.9593269Z ##[error]DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
  DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
  ERROR: Could not find a version that satisfies the requirement django==3.1.4
  ERROR: No matching distribution found for django==3.1.4
  
  2020-12-26T14:54:34.7576240Z ##[error]Error: Unable to run the script on Kudu Service. Error: Error: Executed script returned '1' as return code. Error: DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
  DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
  ERROR: Could not find a version that satisfies the requirement django==3.1.4
  ERROR: No matching distribution found for django==3.1.4
  
  2020-12-26T14:54:36.2470993Z Successfully updated deployment History at https://xxx-dev.scm.azurewebsites.net/api/deployments/321608994474759
  2020-12-26T14:54:36.5240518Z App Service Application URL: http://xxx-dev.azurewebsites.net
  2020-12-26T14:54:36.5358824Z ##[section]Finishing: Deploy Azure App Service
  </code></pre>
  <p>is this known - and more important is there a way to fix this?</p>
  <p>Interestingly, when I ssh into the web app / app service and execute the commands all works fine</p>