none
How do I run apt-get in a linux version of the azure webapp to import a package? RRS feed

  • Question

  • I am trying to import cv2 in a Flask webapp and I get the following message.

    2019-08-16T11:48:05.463405860Z [2019-08-16 11:48:05 +0000] [33] [INFO] Listening at: http://0.0.0.0:8000 (33)
    2019-08-16T11:48:05.464019463Z [2019-08-16 11:48:05 +0000] [33] [INFO] Using worker: sync
    2019-08-16T11:48:05.473083709Z [2019-08-16 11:48:05 +0000] [36] [INFO] Booting worker with pid: 36
    2019-08-16T11:48:08.491099586Z [2019-08-16 11:48:08 +0000] [36] [ERROR] Exception in worker process
    2019-08-16T11:48:08.491136486Z Traceback (most recent call last):
    2019-08-16T11:48:08.491142286Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    2019-08-16T11:48:08.491146186Z     worker.init_process()
    2019-08-16T11:48:08.491149586Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
    2019-08-16T11:48:08.491153086Z     self.load_wsgi()
    2019-08-16T11:48:08.491156386Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
    2019-08-16T11:48:08.491159886Z     self.wsgi = self.app.wsgi()
    2019-08-16T11:48:08.491163086Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
    2019-08-16T11:48:08.491175986Z     self.callable = self.load()
    2019-08-16T11:48:08.491179686Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
    2019-08-16T11:48:08.491182986Z     return self.load_wsgiapp()
    2019-08-16T11:48:08.491186186Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
    2019-08-16T11:48:08.491189686Z     return util.import_app(self.app_uri)
    2019-08-16T11:48:08.491192986Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
    2019-08-16T11:48:08.491196286Z     __import__(module)
    2019-08-16T11:48:08.491199486Z   File "/home/site/wwwroot/Webapp/main.py", line 12, in 
    2019-08-16T11:48:08.491203086Z     import cv2
    2019-08-16T11:48:08.491206386Z   File "/home/site/wwwroot/antenv3.6/lib/python3.6/site-packages/cv2/__init__.py", line 3, in 
    2019-08-16T11:48:08.491209886Z     from .cv2 import *
    2019-08-16T11:48:08.491213086Z ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
    2019-08-16T11:48:08.497759820Z [2019-08-16 11:48:08 +0000] [36] [INFO] Worker exiting (pid: 36)
    2019-08-16T11:48:08.652109211Z [2019-08-16 11:48:08 +0000] [33] [INFO] Shutting down: Master
    2019-08-16T11:48:08.652493413Z [2019-08-16 11:48:08 +0000] [33] [INFO] Reason: Worker failed to boot.

    To solve i try running apt-get install libgtk2.0-dev at https://rvvoting.scm.azurewebsites.net/DebugConsole but i get this error

    E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
    E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
    
    /home> 
    So what is the way to import cv2

    Also, i tried running it on the web ssh, connection automatically closes in a few seconds.
    Friday, August 16, 2019 12:08 PM

All replies

  • I am unable to import cv2 in my main.py of the flask application. i get the following error.

    [2019-08-16 16:52:47 +0000] [36] [ERROR] Exception in worker process
    2019-08-16T16:52:47.225645154Z Traceback (most recent call last):
    2019-08-16T16:52:47.225649654Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    2019-08-16T16:52:47.225653254Z     worker.init_process()
    2019-08-16T16:52:47.225656554Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
    2019-08-16T16:52:47.225660054Z     self.load_wsgi()
    2019-08-16T16:52:47.225663154Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
    2019-08-16T16:52:47.225667054Z     self.wsgi = self.app.wsgi()
    2019-08-16T16:52:47.225670554Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
    2019-08-16T16:52:47.225680955Z     self.callable = self.load()
    2019-08-16T16:52:47.225684255Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
    2019-08-16T16:52:47.225687455Z     return self.load_wsgiapp()
    2019-08-16T16:52:47.225690555Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
    2019-08-16T16:52:47.225693855Z     return util.import_app(self.app_uri)
    2019-08-16T16:52:47.225698655Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
    2019-08-16T16:52:47.225701955Z     __import__(module)
    2019-08-16T16:52:47.225705055Z   File "/home/site/wwwroot/Webapp/main.py", line 12, in 
    2019-08-16T16:52:47.225708455Z     import cv2
    2019-08-16T16:52:47.225711455Z   File "/home/site/wwwroot/antenv3.6/lib/python3.6/site-packages/cv2/__init__.py", line 3, in 
    2019-08-16T16:52:47.225714855Z     from .cv2 import *
    2019-08-16T16:52:47.225717955Z ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory

    SO i commented import cv2 and deployed and then tried   ssh and ran apt-get update then apt-get install libgtk2.0-dev. and then it worked on the ssh when i typed python and then import cv2.

    However, when i deploy the app again with import cv2, i get the same error and the ssh is unreachable.

    Friday, August 16, 2019 5:01 PM
  • UPDATE: 

    SO i commented import cv2 and deployed and then tried   ssh and ran apt-get update then apt-get install libgtk2.0-dev. and then it worked on the ssh when i typed python and then import cv2.

    However, when i deploy the app again with import cv2, i get the same error and the ssh is unreachable.

    Friday, August 16, 2019 5:04 PM
  • Hello Shobhit, we would like to work closer with you on this matter to better understand the issue. Can you please reach out to us at azcommunity@microsoft.com with your subscription ID and the URL of this post? We look forward to your reply.
    Saturday, August 17, 2019 8:31 PM
    Moderator