Check module without import it

member thudfoo thudfoo at opensuse.us
Mon Jun 22 11:05:26 EDT 2009


On Mon, Jun 22, 2009 at 3:06 AM, Kless<jonas.esp at googlemail.com> wrote:
> Is there any way to check that it's installed a module without import
> it directly?
>
> I'm using the nex code but it's possible that it not been necessary to
> import a module
>
> -----------------
> try:
>   import module
> except ImportError:
>   pass
> else:
>   print 'make anything'
> -----------------

Have a look at  find_module in the imp module of the standard library.



More information about the Python-list mailing list