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


Groups > comp.lang.python > #82221

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

Path csiph.com!usenet.pasdenom.info!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.astraweb.com!border6.newsrouter.astraweb.com!not-for-mail
From sohcahtoa82@gmail.com.remove-cdt-this
To Jean-Michel Pichavant
Subject Re: [newbie] how to make program suggest to install missing modules
Message-ID <54866F2E.1759.complang@piz.noip.com> (permalink)
X-Comment-To Jean-Michel Pichavant
Newsgroups comp.lang.python
X-FTN-AREA COMP.LANG.PYTHON
X-FTN-PID SoupGate-Win32 v1.05
X-FTN-MSGID <f46868d7-bce2-440b-a5e6-a9eea44aa62d@googlegroups.com> a2537b89
X-FTN-REPLY <mailman.16730.1418064395.18130.python-list@python.org> beb95f2a
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway piz.noip.com [Synchronet 3.15b-Win32 NewsLink 1.92]
X-Server piz.noip.me
Date 9 Dec 2014 11:32:01 -0500
Lines 38
Organization Unlimited download news at news.astraweb.com
NNTP-Posting-Host 2266ad8f.news.astraweb.com
X-Trace DXC=LP`[=a9Aa>EjEc;hW[JGKHL?0kYOcDh@JRScV177L_PAZh[e@ZS;QSCl23]GVn`ZmFMHo6fPSBkUK04hIVDTD?[K7g\XjYcGehIfPiGS6_2a\M
X-Received-Bytes 2385
X-Received-Body-CRC 460857195
Xref csiph.com comp.lang.python:82221

Show key headers only | View raw


  To: Jean-Michel Pichavant
On Monday, December 8, 2014 10:46:47 AM UTC-8, Jean-Michel Pichavant wrote:
> ----- 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.

Good point.

Of course, imp.find_module ALSO throws ImportError if the module can't be 
found, but at least in that case, you'd know the exact cause.

--- SoupGate-Win32 v1.05
 * Origin: <SpaceSST.BBS.Fidonet<>NNTP.gateway.@.piz.noip.me> (1:249/999)
--- Synchronet 3.15b-Win32 NewsLink 1.92
SpaceSST BBS Usenet <> Fidonet Gateway

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


Thread

Re: [newbie] how to make program suggest to install missing modules sohcahtoa82@gmail.com.remove-cdt-this - 2014-12-09 11:32 -0500

csiph-web