How can I know if a Python module exists, without importing it?

Importing something that might not exist (not what I want) results in:

try:
    import eggs
except ImportError:
    pass

14 Answers
14

Leave a Reply

Your email address will not be published. Required fields are marked *