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 advance16 Replies
I recommend using the aptPkgs field in nixpacks.tomorrow
Nixpacks.toml
Autocorrect moment
Tried using aptPkgs, it's installing, but still the same problem
Not sure ur installing libel
Libgl
It seams to be installing, I will add a cmd to check the version installed...
The response for
apt list libgl1-mesa-glx
was:
libgl1-mesa-glx/jammy-updates,now 22.0.5-0ubuntu0.1 amd64 [installed]
Weird
😖
So I don’t think the so file is in the right place
That's the structure...
No apt is putting it in the wrong place
Or python is looking in the wrong place
oh, got it...
up
yeah not much we can do
it's just apt being annoying
Solved with a Dockerfile
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
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"]