Deploying a Django app on azure - No module named django

HUuzaifa Azhar 31 Reputation points
2022-07-07T18:00:51.89+00:00

0

I am trying to deploy a django web app on azure but I am having no success with it! I have tried different methods for deployment (VSCode, Zip file, github..)and have followed different Qs on StackOverflow and other forums but in vain. Now I am trying to deploy using a zip file and getting the following error in logs:

   2022-07-07T17:48:18.453487609Z Traceback (most recent call last):  
   2022-07-07T17:48:18.453492410Z   File "/opt/python/3.9.7/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker  
   2022-07-07T17:48:18.453496310Z     worker.init_process()  
   2022-07-07T17:48:18.453515311Z   File "/opt/python/3.9.7/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process  
   2022-07-07T17:48:18.453519511Z     self.load_wsgi()  
   2022-07-07T17:48:18.453522711Z   File "/opt/python/3.9.7/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi  
   2022-07-07T17:48:18.453526111Z     self.wsgi = self.app.wsgi()  
   2022-07-07T17:48:18.453529411Z   File "/opt/python/3.9.7/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi  
   2022-07-07T17:48:18.453532912Z     self.callable = self.load()  
   2022-07-07T17:48:18.453536112Z   File "/opt/python/3.9.7/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load  
   2022-07-07T17:48:18.453539512Z     return self.load_wsgiapp()  
   2022-07-07T17:48:18.453542712Z   File "/opt/python/3.9.7/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp  
   2022-07-07T17:48:18.453546112Z     return util.import_app(self.app_uri)  
   2022-07-07T17:48:18.453549312Z   File "/opt/python/3.9.7/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app  
   2022-07-07T17:48:18.453552813Z     mod = importlib.import_module(module)  
   2022-07-07T17:48:18.453556013Z   File "/opt/python/3.9.7/lib/python3.9/importlib/__init__.py", line 127, in import_module  
   2022-07-07T17:48:18.453559413Z     return _bootstrap._gcd_import(name[level:], package, level)  
   2022-07-07T17:48:18.453562713Z   File "
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
{count} votes

3 answers

Sort by: Most helpful
  1. ajkuma 28,036 Reputation points Microsoft Employee Moderator
    2022-07-14T15:46:48.767+00:00

    To benefit the community, posting the solution that worked for @HUuzaifa Azhar (Thanks for sharing the solution).

    Solved it by setting ENABLE_ORYX_BUILD = true in app settings

    Additional info on the app setting document:
    ENABLE_ORYX_BUILD - if true, use the Oryx build system instead of the legacy Kudu system
    SCM_DO_BUILD_DURING_DEPLOYMENT - if false, bypass automatic build

    --
    To benefit the community find the right answers, please do mark the post which was helpful by clicking on Accept Answer’ & ‘Up-Vote’.

    1 person found this answer helpful.
    0 comments No comments

  2. Krishan Sritharar 1 Reputation point
    2022-08-05T11:00:57.417+00:00

    Just to add onto the message above, for anyone still experiencing the issue afterwards, my fix was to:

    Add gunicorn to requirements.txt

    By looking in the webapp's Application Logs, this change helped find the correct build manifest file, and then the correct build operation id. All this resulting in the correct virtual environment being detected and used.

    0 comments No comments

  3. Chukwuemeka Aladimma 0 Reputation points
    2023-11-01T23:05:54.84+00:00

    Two things helped me resolve this issue.

    1. Adding gunicorn to my requirements.txt file
    2. Creating an app setting, SCM_DO_BUILD_DURING_DEPLOYMENT, and setting it to 1

    For more details on 2, read this: https://learn.microsoft.com/en-us/azure/app-service/configure-language-python#modulenotfounderror-when-app-starts

    0 comments No comments

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.