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

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=412f4c609=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.054
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; 'subject:: [': 0.04; 'importerror:': 0.07; 'subject:missing': 0.07; 'subject:modules': 0.09; 'try:': 0.09; 'cc:addr:python-list': 0.11; 'importerror': 0.16; 'subject:install': 0.16; 'subject:make': 0.16; 'subject:program': 0.16; 'subject:] ': 0.20; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'install': 0.23; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'raised': 0.31; 'url:python': 0.33; '-----': 0.33; 'could': 0.34; 'except': 0.35; 'module.': 0.36; 'url:org': 0.36; 'thank': 0.38; 'url:library': 0.38; 'handle': 0.38; 'sure': 0.39; 'you.': 0.62; 'making': 0.63; 'email addr:gmail.com': 0.63; 'information': 0.63; 'received:194': 0.64; 'to:addr:gmail.com': 0.65; 'it!': 0.67; 'notice:': 0.67; 'person,': 0.68; 'privileged.': 0.69; 'disclose': 0.74; 'safer': 0.84; 'url:imp': 0.84; 'medium.': 0.91
X-IronPort-AV E=Sophos;i="5.07,540,1413237600"; d="scan'208";a="3702941"
Date Mon, 8 Dec 2014 19:46:33 +0100 (CET)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To sohcahtoa82@gmail.com
In-Reply-To <0757295c-1dac-40e8-9ebb-2128a7d41e38@googlegroups.com>
Subject Re: [newbie] how to make program suggest to install missing modules
MIME-Version 1.0
X-Mailer Zimbra 7.2.7_GA_2942 (ZimbraWebClient - GC39 (Win)/7.2.7_GA_2942)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16730.1418064395.18130.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1418064395 news.xs4all.nl 2916 [2001:888:2000:d::a6]:39677
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82137

Show key headers only | 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