Cannot start virtual enviroment on Azure Web App Linux server

Adam Tamargo 6 Reputation points
2021-01-27T17:56:51.06+00:00

I am trying to deploy my Django application to a Linux Web App server on Azure. For this to work properly I need to be using Python 3.8 and install all the required modules listed in the requirements.txt file that is located in the wwwroot directory after deployment. I am attempting to setup my virtual environment via the following (from my azure-pipelines.yml file):

- bash: |
        python3.8 -m venv worker_venv
        source worker_venv/bin/activate
        pip3.8 install setuptools
        pip3.8 install --target="./.python_packages/lib/site-packages" -r 
        requirements.txt
      workingDirectory: $(projectRoot)
      displayName: "Install requirements"

I know, from checking in the Kudu debug console, that the dependancies all get installed to /home/.local/lib/python2.7/site-packages rather than the virtual environment's directory for them, /home/site/wwwroot/worker_venv/lib/python3.8/site-packages. Also, by checking 'python --version' I know I am running python 2.7 rather than 3.8 as specified by the venv.

I am thinking the issue is that the 'source worker_venv/bin/activate' line is not activating the venv and therefore I am stuck with Python 2.7. This will not do as my project requires 3.8.

Thank you for any assistance. Please let me know if there is any additional information I can provide.

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

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 14,476 Reputation points Microsoft Employee
    2021-01-28T06:59:20.737+00:00

    @Adam Tamargo It appears you are using a Linux web app and not a Linux container web app, correct?

    The first item that comes to mind is to check your app settings in the Azure Portal, as shown in the portal to ensure you've declared the proper runtime and minor version.

    61258-image.png

    Can you please check this item? There shouldn't really be much else required to properly declare the runtime if you're using a non-container app.

    We look forward to your reply.