a year ago
I'm trying to deploy a flask application that uses opencv but its failing to deploy. This is the error it throws during deployment: ImportError: [libGL.so](libGL.so).1: cannot open shared object file: No such file or directory
I want to ask if there's any way I can use the Nixipack to build the app while also run few commands inside the docker container to install few missing dependencies i.e. apt-get update && apt-get install libgl1
I've tried using headless opencv but it still threw same error.
Any help will be extremely appreciated!!
5 Replies
a year ago
Here's the full stacktrace:
[2024-04-14 07:07:05 +0000] [7] [INFO] Starting gunicorn 20.0.4
[2024-04-14 07:07:05 +0000] [7] [INFO] Listening at: http://0.0.0.0:5820 (7)
[2024-04-14 07:07:05 +0000] [7] [INFO] Using worker: sync
[2024-04-14 07:07:05 +0000] [10] [INFO] Booting worker with pid: 10
[2024-04-14 07:07:05 +0000] [10] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/opt/venv/lib/python3.11/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/opt/venv/lib/python3.11/site-packages/gunicorn/workers/base.py", line 119, in init_process
self.load_wsgi()
File "/opt/venv/lib/python3.11/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
self.wsgi = self.app.wsgi()
^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.11/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
^^^^^^^^^^^
File "/opt/venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
return self.load_wsgiapp()
^^^^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.importapp(self.appuri)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.11/site-packages/gunicorn/util.py", line 358, in import_app
mod = importlib.import_module(module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.nix-profile/lib/python3.11/importlib/init.py", line 126, in import_module
return bootstrap.gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1204, in gcdimport
File "", line 1176, in findand_load
File "", line 1147, in findandloadunlocked
File "", line 690, in loadunlocked
File "", line 940, in exec_module
File "", line 241, in callwithframesremoved
File "/app/handy_web.py", line 1, in
import cv2
File "/opt/venv/lib/python3.11/site-packages/cv2/init.py", line 181, in
bootstrap()
File "/opt/venv/lib/python3.11/site-packages/cv2/init.py", line 153, in bootstrap
nativemodule = importlib.importmodule("cv2")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.nix-profile/lib/python3.11/importlib/init.py", line 126, in import_module
return bootstrap.gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
[2024-04-14 07:07:05 +0000] [10] [INFO] Worker exiting (pid: 10)
[2024-04-14 07:07:05 +0000] [7] [INFO] Shutting down: Master
[2024-04-14 07:07:05 +0000] [7] [INFO] Reason: Worker failed to boot.
a year ago
you can use nixpacts config to install additional apt/nix packages
eisest done via ENV vars
https://nixpacks.com/docs/configuration/environment
or you can write a toml config file
a year ago
I've tired setting up variable to make nixpacks download the apt packages and it did download them but I'm still getting the same error.
a year ago
are you sure you are adding the correct pacakges? usually you need to add -dev version of packages that include headers and other libs that can be than linked when you are building your python lib