ModuleNotFoundError: No module named 'django' by Deploying on Azure

1.2k views Asked by At

I'm trying to deploy a django web app to the Microsoft Azure and this is correctly deployed by the pipeline on DevOps Azure, but I get the error message (ModuleNotFoundError: No module named 'django) on portal Azure and cannot reach my app via the URL. The app also works properly locally Here is the whole error message: '''https://pastebin.com/mGHSS8kQ'''

How can I solve this error?

1

There are 1 answers

0
AjayKumar On

I understand you have tried the steps suggested in the SO thread Eyap shared, and few things here are already covers that. Kindly review these settings.

You can use this command instead - source /antenv3.6/bin/activate.

As a side note- The antenv will be available only after a deployment is initiated. Kindly check the “/” path from SSH and you should see a folder with name starting from antenv.

Browse to .python_packages/lib/python3.6/site-packages/ or .python_packages/lib/site-packages/. Kindly review the file path exists.

Review the Application logs as well (/home/LogFiles folder) from Kudu- https://<yourwebpp-name>.scm.azurewebsites.net/api/logs/docker

The App Service deployment engine automatically activates a virtual environment and runs

pip install -r requirements.txt

The requirements.txt file must be in the project root for dependencies to be installed.

For Django apps, App Service looks for a file named wsgi.py within your app code, and then runs Gunicorn using the following command:

is the name of the folder that contains wsgi.py

gunicorn --bind=0.0.0.0 --timeout 600 .wsgi

If you want more specific control over the startup command, use a custom startup command, replace with the name of folder that contains wsgi.py, and add a --chdir argument if that module is not in the project root.

For additional details, please checkout this document

Configure a Linux Python app for Azure App Service

Quickstart: Create a Python app in Azure App Service on Linux