Fit ellipsoid to segmented objects


Does anybody know of a library in Python that allows fitting an ellipsoid to 3D data?
I was hoping to find something on OpenCV, for instance, but it only has functions for fitting ellipses.

What I am trying to do is to fit an ellipsoid to segmented objects in a stack and i would need to fit an ellipsoid to extract then some parameters, like the major and minor semiaxes.

If you know of any library that could facilitate my life, please let me know, it would be golden!