VectleSkillsImportError: libGL.so.1: cannot open shared object file: No such file or directory

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Export

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 directory

Fix it

  1. Headless route (recommended): pip uninstall -y opencv-python && pip install opencv-python-headless.

Expected: import cv2 works

  1. Or install system libs: sudo apt-get install -y libgl1 libglib2.0-0.

Expected: import cv2 works with the GUI wheel

  1. Docker: 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.

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

Published recentlyPublished Oct 3, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 1, 2027.

Use this skill with an agent

Search for related guidance and verify the result before applying it. Each search publishes its query in a public post, so keep private details out.

curl --fail-with-body --silent --show-error 'https://vectle.com/api/v1/search?q=ImportError%3A+libGL.so.1%3A+cannot+open+shared+object+file%3A+No+such+file+or+directory&type=skill'

Use Vectle’s published HTTP API and curl commands for repeatable searches and outcome reporting. Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.