Used nixpacks.toml to install apt packages on build, but they are not recognized on deploy

It's a python 3.9 app running a Neural Network that uses the openCV library, which is bringing an import error... The ImportError says that it was not possible to find libGL.so.1:
import cv2 File "/opt/venv/lib/python3.9/site-packages/cv2/init.py", line 181, in <module> bootstrap() File "/opt/venv/lib/python3.9/site-packages/cv2/init.py", line 153, in bootstrap native_module = importlib.import_module("cv2") File "/nix/store/3nqphv9yn73s20cf3circdf3mc9hlv7f-python3-3.9.15/lib/python3.9/importlib/init.py", line 127, 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 [9] [INFO] Worker exiting (pid: 9) [1] [INFO] Shutting down: Master [1] [INFO] Reason: Worker failed to boot.
Then I added a nixpacks.toml config file to install that apt package: [phases.setup] cmds = [ 'sudo dpkg --add-architecture i386', 'sudo apt-get update', 'sudo apt-get -y upgrade', 'sudo apt-get -y install freeglut3-dev libgtk2.0-dev libgl1-mesa-glx tesseract-ocr libtesseract-dev libtesseract4 tesseract-ocr-all' ] The apt packages were successfully installed as it's possible to see in the print, but the ImportError keep popping up.... Any ideas? Thanks in advance
16 Replies
milo
milo•2y ago
I recommend using the aptPkgs field in nixpacks.tomorrow
Finn
Finn•2y ago
Nixpacks.toml Autocorrect moment
Yuri Achermann
Yuri AchermannOP•2y ago
Tried using aptPkgs, it's installing, but still the same problem squidpepe
milo
milo•2y ago
Not sure ur installing libel Libgl
Yuri Achermann
Yuri AchermannOP•2y ago
It seams to be installing, I will add a cmd to check the version installed...
Yuri Achermann
Yuri AchermannOP•2y ago
The response for apt list libgl1-mesa-glx was: libgl1-mesa-glx/jammy-updates,now 22.0.5-0ubuntu0.1 amd64 [installed]
milo
milo•2y ago
Weird
Yuri Achermann
Yuri AchermannOP•2y ago
😖
milo
milo•2y ago
So I don’t think the so file is in the right place
Yuri Achermann
Yuri AchermannOP•2y ago
That's the structure...
milo
milo•2y ago
No apt is putting it in the wrong place Or python is looking in the wrong place
Yuri Achermann
Yuri AchermannOP•2y ago
oh, got it... up
milo
milo•2y ago
yeah not much we can do it's just apt being annoying
Yuri Achermann
Yuri AchermannOP•2y ago
Solved with a Dockerfile
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Yuri Achermann
Yuri AchermannOP•2y ago
FROM python:3.10-slim-buster WORKDIR /app RUN apt-get update && apt-get install -y libgl1-mesa-glx libglib2.0-0 libsm6 libxext6 libxrender-dev COPY requirements.txt requirements.txt RUN pip3 install -r requirements.txt COPY . . EXPOSE 8080 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"]
Want results from more Discord servers?
Add your server