There is now a headless version of opencv-python
which removes the graphical dependencies (like libSM). You can see the normal / headless version on the releases page (and the GitHub issue leading to this); just add -headless
when installing, e.g.,
pip install opencv-python-headless
# also contrib, if needed
pip install opencv-contrib-python-headless