question

AdamTamargo-8775 avatar image
0 Votes"
AdamTamargo-8775 asked ·

Cannot start virtual enviroment on Azure Web App Linux server

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-webappsazure-webapps-availability
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

brtrachMSFT-0711 avatar image
0 Votes"
brtrachMSFT-0711 answered ·

@AdamTamargo-8775 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.



image.png (23.2 KiB)
· 2 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I realized that I was missing the gunicorn dependency in my requirements.txt. Adding this solved my issue. Sorry for the inconvenience and thank you for the help.

1 Vote 1 ·

Thank you for the sharing the resolution with the community for others who might have a similar issue in the future.

0 Votes 0 ·