krishauser / Klampt

Kris' Locomotion and Manipulation Planning Toolkit
BSD 3-Clause "New" or "Revised" License
378 stars 96 forks source link

Missing dependency for `pip install klampt` on Unix systems #185

Closed FlurinArner closed 5 months ago

FlurinArner commented 5 months ago

I faced following ImportError while installing with pip install klampt ImportError: libOpenGL.so.0: cannot open shared object file: No such file or directory

So I decided to replicate the issue on Ubuntu 22.04, Ubuntu 24.04, Python3.10 and Python3.12 (both based on Debian bookworm) with the following dockerfile:

FROM ubuntu:22.04
# FROM ubuntu:24.04
# FROM python:3.10
# FROM python:3.12

WORKDIR /usr/src/app

# Update the system
# Install dependencies, but disable the recommended packages, so to save space
#       as explained here: https://ubuntu.com/blog/we-reduced-our-docker-images-by-60-with-no-install-recommends
RUN DEBIAN_FRONTEND="noninteractive" \
    apt-get clean && apt-get update && \
    apt-get install --no-install-recommends --yes \
    python3-pip python3-venv

# Comment the following line out, for ImportError
RUN DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends --yes qtbase5-dev

RUN python3 -m venv .venv

CMD ["/usr/bin/bash"]

In all cases (select any of the first 4 lines), if qtbase5-dev was not installed, I would encounter the missing libOpenGL.so.0.

I tried with a few other dependencies from the dependency list mentioned in the building from source manual, but nothing solved the issue like qtbase5-dev (which is somewhat a replacement for the obsolete qt5-default package).

I'm not sure what the solution to this problem would be. Do these packages need to be installed system-wide? Would it suffice to add some "warning" if after doing pip install klampt the necessary libraries are installed?

FlurinArner commented 5 months ago

Tested with Docker version 26.1.3, build b72abbb:

As is, no errors occurred, all is good (at least for now, just for importing klampt). If the line with qtbase5-dev is commented out, ImportErrors occur.

P.S. the 'venv activation' is not strictly necessary in all scenarios, but causes issues with Ubuntu 23+ when executing pip install ...

krishauser commented 5 months ago

Thanks for pointing this out, I'll update the docs!

FlurinArner commented 5 months ago

Upon further investigation, as I was solving unrelated issues, I noticed it's enough to install the necessary libraries:

Or in a Dockerfile format as above:

RUN DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends --yes libopengl0 libgl1-mesa-glx