Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82137

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

Date 2014-12-08 19:46 +0100
From Jean-Michel Pichavant <jeanmichel@sequans.com>
Subject Re: [newbie] how to make program suggest to install missing modules
Newsgroups comp.lang.python
Message-ID <mailman.16730.1418064395.18130.python-list@python.org> (permalink)

Show all headers | View raw


----- Original Message -----
> From: sohcahtoa82@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.

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: [newbie] how to make program suggest to install missing modules Jean-Michel Pichavant <jeanmichel@sequans.com> - 2014-12-08 19:46 +0100
  Re: [newbie] how to make program suggest to install missing modules sohcahtoa82@gmail.com - 2014-12-08 11:59 -0800
    Re: [newbie] how to make program suggest to install missing modules hugocoolens <hugocoolens@gmail.com> - 2014-12-12 02:52 -0800
      Re: [newbie] how to make program suggest to install missing modules Chris Warrick <kwpolska@gmail.com> - 2014-12-12 13:59 +0100

csiph-web