How do I canonically determine/find/identify, without having the package installed, which package(s) a given module belongs to (so I can install it)?
I have a legacy code base. It has lots of import
statements. If I want to install the referenced modules, say to populate setup.py
, I need to know the package names, but there is no necessary relationship between the name of the module and the name of the package. For example, an import cv2
is satisfied by the package opencv-python
, not cv2
. I'm left with googling, which is less than a satisfying solution.
It seems like this would be a common problem with a well-defined answer, but darned if I can find it. I found an answer that assumes the package is installed, but I want an answer if the package is not installed.