Solution skill
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
Complete solution
Fixes ImportError: libGL.so.1: cannot open shared object file: No such file or directory Use when `import cv2` fails on libGL.so.1 (or libgthread) in Docker/CI/headless Linux Not for: you actually need cv2.imshow (then install the libs, do not go headless)
How to fix ImportError: libGL.so.1: cannot open shared object file: No such file or directory
You are on a headless box and opencv-python wants GUI system libs. Two fixes: install the lib (sudo apt-get install libgl1, often plus libglib2.0-0), or switch to the headless wheel: pip install opencv-python-headless. The headless wheel is the right call for servers and Docker; it has no GUI deps at all.
The exact error
ImportError: libGL.so.1: cannot open shared object file: No such file or directoryFix it
Headless route (recommended):
pip uninstall -y opencv-python && pip install opencv-python-headless. Expected:import cv2worksOr install system libs:
sudo apt-get install -y libgl1 libglib2.0-0. Expected:import cv2works with the GUI wheelDocker: add the apt line to your Dockerfile before pip install. Expected: container imports cv2 cleanly
When this applies
import cv2 fails on libGL.so.1 (or libgthread) in Docker/CI/headless Linux
When this does NOT apply
you actually need cv2.imshow (then install the libs, do not go headless)
Versions
Linux Docker / headless servers, opencv-python
Why it happens
opencv-python links Qt/OpenGL system libraries that slim images do not ship.
Edge cases
Never install both opencv-python and opencv-python-headless; they conflict.
Evidence
Asked about: ImportError: libGL.so.1: cannot open shared object file: No such file or directory (gh:stabrise/scaledp#93). The verified fix: You are on a headless box and opencv-python wants GUI system libs. Two fixes: install the lib (sudo apt-get install libgl1, often plus libglib2.0-0), or switch to the headless wheel: pip install opencv-python-headless. The headless wheel is the right call for servers and Docker; it has no GUI deps at all. Full thread: https://github.com/stabrise/scaledp/issues/93
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_QNbndoq6D_ru5_WAdxnRkQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">ImportError: libGL.so.1: cannot open shared object file: No such file or directory <span>— Vectle</span></a>