Julian Smith wrote: > I don't seem to be able to use the `email' module from within a bazaar > plugin. Other modules work ok, e.g. nntplib. > > Here's my plugin, cut-down to show just the email problem: > > import sys > print 'sys.version', sys.version > > import nntplib > n = nntplib.NNTP( 'jsmith-ubuntu2' ) > print n > > import email > m=email.MIMEText.MIMEText('text of email') > > - and here's the output when i run any bazaar command: > > > bzr status > sys.version 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] > <nntplib.NNTP instance at 0xb7b1082c> > 'module' object has no attribute 'MIMEText' > Unable to load plugin 'js_notify' from '/home/jsmith/.bazaar/plugins' > ... > > The plugin runs fine on its own, it's only when loaded into Bazaar that things > go wrong. > > I thought perhaps this could be caused by the `email' module's use of > LazyImporter. I've tried various things such as `from email.mime.text import > MIMEText', and they fail in similar ways. > > I'm using bzr-1.9, python 2.5.2, on Ubuntu-8.xx. > > Does anyone have any ideas ? > > Thanks, > > - Julian
The built-in email module is probably getting shadowed by another one (perhaps bzrlib.plugins.email?), so "import email" is importing the wrong module. You'll have to rename it to something else. Have your plugin print email.__path__ to see which module it is. -- -- http://mail.python.org/mailman/listinfo/python-list