Induane
Induane
RRailway
Created by Induane on 2/6/2024 in #✋|help
Deploy issue with Python PIL/Pillow and libwebp.so.7 not found
I'm running into what seems like a fairly simple deploy issue:
from faerymarket.utils import image
File "/opt/venv/lib/python3.11/site-packages/faerymarket/utils/image.py", line 9, in <module>
from PIL import Image as PILImage
File "/opt/venv/lib/python3.11/site-packages/PIL/Image.py", line 114, in <module>
from . import _imaging as core
ImportError: libwebp.so.7: cannot open shared object file: No such file or directory
from faerymarket.utils import image
File "/opt/venv/lib/python3.11/site-packages/faerymarket/utils/image.py", line 9, in <module>
from PIL import Image as PILImage
File "/opt/venv/lib/python3.11/site-packages/PIL/Image.py", line 114, in <module>
from . import _imaging as core
ImportError: libwebp.so.7: cannot open shared object file: No such file or directory
In my earlier attempts, I simply couldn't get the package to build, so I updated the railway.json file to include the build dependencies. Here is my railway.json file:
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"phases": {
"setup": {
"aptPkgs": ["...", "libtiff5-dev" , "libjpeg-dev", "libopenjp2-7-dev", "zlib1g-dev", "libfreetype6-dev", "liblcms2-dev", "libwebp-dev", "libharfbuzz-dev", "libfribidi-dev", "libxcb1-dev"]
}
}
}
},
"deploy": {
"numReplicas": 1,
"startCommand": "python src/faerymarket/manage.py migrate && python src/faerymarket/manage.py collectstatic --noinput --clear && bin/uwsgi --ini=src/faerymarket/api.ini",
"healthcheckPath": "health/",
"sleepApplication": false,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"phases": {
"setup": {
"aptPkgs": ["...", "libtiff5-dev" , "libjpeg-dev", "libopenjp2-7-dev", "zlib1g-dev", "libfreetype6-dev", "liblcms2-dev", "libwebp-dev", "libharfbuzz-dev", "libfribidi-dev", "libxcb1-dev"]
}
}
}
},
"deploy": {
"numReplicas": 1,
"startCommand": "python src/faerymarket/manage.py migrate && python src/faerymarket/manage.py collectstatic --noinput --clear && bin/uwsgi --ini=src/faerymarket/api.ini",
"healthcheckPath": "health/",
"sleepApplication": false,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
The custom build command is:
python -m pip install .
python -m pip install .
This all works fine with the exception of the inability to import the image library. My best guess, because I'm only partway though a lot of the docs, is that perhaps the setup phase packages aren't included in the final image layer? Does anyone have any ideas I could try?
13 replies