[newbie] how to make program suggest to install missing modules

Jean-Michel Pichavant jeanmichel at sequans.com
Mon Dec 8 13:46:33 EST 2014


----- Original Message -----
> From: sohcahtoa82 at gmail.com
> try:
>     import someModule
> except ImportError:
>     print "Module is missing"
>     # handle it!
> 
> Just make sure to attempt to import it again after making the call to
> pip to install it.

Note that ImportError may be raised for other reasons than a missing module.

Check https://docs.python.org/2/library/imp.html and the imp.find_module, it could be a safer way to check for a missing module.

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


More information about the Python-list mailing list