[Mailman-Users] Mandrake 9.1 / ImportError: No module namedgetopt

Richard Barrett r.barrett at openinfo.co.uk
Tue May 13 14:31:44 CEST 2003


At 12:46 13/05/2003, Oliver.Egginger at dvz.fh-giessen.de wrote:
>Richard Barrett <r.barrett at openinfo.co.uk> wrote:
> > >
> > >It seems that it is caused by the line 255 from mailmanctl:
> > >
> > >os.execl(mm_cfg.PYTHON, 'qrunner', exe, rswitch, '-s')
> >
> > Just a thought, but what is the value of the variable PYTHON in
> > $prefix/Mailman/Defaults.py and is this the same as the results of
> > executing "which python" from the command line?
> >
>
>Default.py keeps:
>PYTHON          = '/usr/bin/python'
>and there are no overrides in mm.cfg.
>The command 'ls -l /usr/bin/python' shows me:
>-rwxr-xr-x    1 root     root         3712 Feb  5 10:41 /usr/bin/python*
>
>Also if there where a wrong path it should break with a command
>or file not found error, I think.
>

I was thinking more of two versions of python installed but that doesn't 
look to be the case from what you say. And given mailmanctl imported getopt 
OK how come the execl'd python cannot.

The only difference between execution of the python instance running 
mailmanctl and the execl'd python instance is the -S option on the latter 
while tells python not to automatically run the 'import site' statement 
when it start execution. For instance on my system running python from the 
command line with and without the -S option produces a different value for 
sys.path:

<example>
mailman at mailman2:/mailman/run/bin> python
Python 2.2.2 (#3, Feb 11 2003, 16:57:53)
[GCC 2.95.3 20010315 (SuSE)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import sys
 >>> sys.path
['', '/usr/local/lib/python2.2', '/usr/local/lib/python2.2/plat-linux2', 
'/usr/local/lib/python2.2/lib-tk', '/usr/local/lib/python2.2/lib-dynload', 
'/usr/local/lib/python2.2/site-packages']
 >>>
mailman at mailman2:/mailman/run/bin> python -S
Python 2.2.2 (#3, Feb 11 2003, 16:57:53)
[GCC 2.95.3 20010315 (SuSE)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import sys
 >>> sys.path
['', '/usr/local/lib/python2.2/', '/usr/local/lib/python2.2/plat-linux2', 
'/usr/local/lib/python2.2/lib-tk', '/usr/local/lib/python2.2/lib-dynload']
 >>> import getopt
 >>> getopt.__file__
'/usr/local/lib/python2.2/getopt.pyc'
 >>>
mailman at mailman2:/mailman/run/bin>
</example>

Try running python from the command line with the -S option and then try to 
import getopt. If this fails then one has to question how python has been 
installed on your system as it would appear that some standard modules are 
installed in the site specific directory rather than their more usual location.


>For example:
>I write a little test script called test.py here it is
>-------------------------------------> SNIP
>#! /usr/bin/python
>
>import getopt
>
>print "Hallo\n";
>
>print (getopt.error);
>print "\n";
>------------------------------------->
>
>If I start it from commandline it works faultless but if I call it
>from within the mailmanctl script changing the lines 254 and 255 to
>the following:
>
>exe = os.path.join(mm_cfg.BIN_DIR, 'test.py')
>os.execl(mm_cfg.PYTHON, 'qrunner', exe, rswitch, '-s')
>
>It produces the error messages:
>------------------------------------------------------------
>'import site' failed; use -v for traceback
>Traceback (most recent call last):
>   File "/home/mailman/bin/test.py", line 3, in ?
>     import getopt
>ImportError: No module named getopt
>Could not find platform independent libraries <prefix>
>Could not find platform dependent libraries <exec_prefix>
>Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
>'import site' failed; use -v for traceback
>-------------------------------------------------------------
>
>It's the same failure I get from the qrunner script,
>which gets normally called at this point from mailmanctl.
>
> > If they are not the same then this might hint at the cause of your 
> problem.
> > Did you add a --with-python option when you ran ./configure? If so with
> > what value?
> >
>
>No. I don't exspect the problem there.
>The python interpreter gets called.
>
>I set
>
>PYTHON          = '/usr/bin/python'
>PREFIX          = '/home/mailman'
>EXEC_PREFIX     = '/usr/lib/python2.2'
>VAR_PREFIX      = '/home/mailman'
>
>Also I did many tests with
>
>EXEC_PREFIX     = '/home/mailman'
>
>No difference.
>
>- oliver
>
>

------------------------------------------------------------------------------
Richard Barrett                                      http://www.openinfo.co.uk





More information about the Mailman-Users mailing list