[Tutor] testing for modules?
Bill Burns
billburns at pennswoods.net
Tue Oct 25 00:41:31 CEST 2005
Ed Hotchkiss wrote:
> i have a generic script that is using several modules on windows and
> linux boxes. i need to have the scripts test if a module is installed,
> and then if not - then to install the module. can anyone give me a
> headsup on how to test for a module, returning something to indicate
> whether or not it is installed, then after that executing file to
> install the module.? just somewhere to start would be helpful! thanks in
> advance.
Hi Ed,
You can at do this to test if a module is installed:
try:
import SomeModule
except ImportError:
print 'SomeModule is not installed!'
I'm not sure about the part regarding the module installation. I guess
you would replace the print statement above with some code to install
the module.
HTH,
Bill
More information about the Tutor
mailing list