Python packages not being installed when using FTP for Azure App Service

shaane 1 Reputation point
2022-09-28T05:34:40.873+00:00

I am trying to start a Flask server using FTP in App service. The server starts up but the python packages are not being installed, even though I have a requirements.txt file.

I have both application.py and requirements.txt in the wwwroot directory of the FTP server.

This is the error I see in the logs:

   2022-09-28T02:00:27.060931618Z [2022-09-28 02:00:27 +0000] [60] [INFO] Starting gunicorn 20.1.0  
   2022-09-28T02:00:27.106296578Z [2022-09-28 02:00:27 +0000] [60] [INFO] Listening at: http://0.0.0.0:8000 (60)  
   2022-09-28T02:00:27.107044772Z [2022-09-28 02:00:27 +0000] [60] [INFO] Using worker: sync  
   2022-09-28T02:00:27.120192573Z [2022-09-28 02:00:27 +0000] [65] [INFO] Booting worker with pid: 65  
   2022-09-28T02:00:29.858503630Z [2022-09-28 02:00:29 +0000] [65] [ERROR] Exception in worker process  
   2022-09-28T02:00:29.859640121Z Traceback (most recent call last):  
   2022-09-28T02:00:29.859653821Z   File "/opt/python/3.7.12/lib/python3.7/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker  
   2022-09-28T02:00:29.859668821Z     worker.init_process()  
   2022-09-28T02:00:29.859673121Z   File "/opt/python/3.7.12/lib/python3.7/site-packages/gunicorn/workers/base.py", line 134, in init_process  
   2022-09-28T02:00:29.859677021Z     self.load_wsgi()  
   2022-09-28T02:00:29.859687721Z   File "/opt/python/3.7.12/lib/python3.7/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi  
   2022-09-28T02:00:29.859691821Z     self.wsgi = self.app.wsgi()  
   2022-09-28T02:00:29.859695421Z   File "/opt/python/3.7.12/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi  
   2022-09-28T02:00:29.859699221Z     self.callable = self.load()  
   2022-09-28T02:00:29.859702721Z   File "/opt/python/3.7.12/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 58, in load  
   2022-09-28T02:00:29.859706521Z     return self.load_wsgiapp()  
   2022-09-28T02:00:29.859710021Z   File "/opt/python/3.7.12/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp  
   2022-09-28T02:00:29.859713820Z     return util.import_app(self.app_uri)  
   2022-09-28T02:00:29.859717620Z   File "/opt/python/3.7.12/lib/python3.7/site-packages/gunicorn/util.py", line 359, in import_app  
   2022-09-28T02:00:29.859721420Z     mod = importlib.import_module(module)  
   2022-09-28T02:00:29.859725020Z   File "/opt/python/3.7.12/lib/python3.7/importlib/__init__.py", line 127, in import_module  
   2022-09-28T02:00:29.859728820Z     return _bootstrap._gcd_import(name[level:], package, level)  
   2022-09-28T02:00:29.859732320Z   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import  
   2022-09-28T02:00:29.859736820Z   File "<frozen importlib._bootstrap>", line 983, in _find_and_load  
   2022-09-28T02:00:29.859740620Z   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked  
   2022-09-28T02:00:29.859744420Z   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked  
   2022-09-28T02:00:29.859748820Z   File "<frozen importlib._bootstrap_external>", line 728, in exec_module  
   2022-09-28T02:00:29.859752620Z   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed  
   2022-09-28T02:00:29.859773920Z   File "/home/site/wwwroot/application.py", line 2, in <module>  
   2022-09-28T02:00:29.859778020Z     from db_config import get_db_config  
   2022-09-28T02:00:29.859781720Z   File "/home/site/wwwroot/db_config.py", line 1, in <module>  
   2022-09-28T02:00:29.859785720Z     import pyodbc  
   2022-09-28T02:00:29.859789320Z ModuleNotFoundError: No module named 'pyodbc'  
   2022-09-28T02:00:29.860328516Z [2022-09-28 02:00:29 +0000] [65] [INFO] Worker exiting (pid: 65)  
   2022-09-28T02:00:30.020219116Z [2022-09-28 02:00:30 +0000] [60] [INFO] Shutting down: Master  
   2022-09-28T02:00:30.020744512Z [2022-09-28 02:00:30 +0000] [60] [INFO] Reason: Worker failed to boot.  

Please note that I am transferring files using FileZilla and don't have access to the UI to use other methods of deployment.

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

1 answer

Sort by: Most helpful
  1. VenkateshDodda-MSFT 22,156 Reputation points Microsoft Employee
    2022-09-29T09:14:44.083+00:00

    @shaane Thank you for reaching out to Microsoft Q&A/ Based on the shared information i understood that you are trying to deploy the python packages to app server using the FTP. As mentioned here in this documentation it is not recommended to use FTP or ZIP deploy to deploy flask app deployment on Linux app service.

    245977-image.png

    I would suggest you to follow this documentation steps and try deploying your python flask app to the Webapp.

    You can also refer to this article for the Module Not error in python webapps.

    Feel free to reach back to me if you have any further questions on this.

    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.