Do you have a file called "email.py" in your current directory or
anywhere else on Python's path outside of the standard library? If so,
it's hiding the real email module from your script and you'll need to
get rid of "your" email.py by renaming or moving it.
--
Carsten Haese
http://informixdb.sourceforge.net
Hello Victor,
There are some pages on the internet that suggest that this problem my be
caused by a module named email.py (or email.pyc) in your pythonpath. If
you try import smtplib in the interpreter do you get this error message?
If so, start a new interpreter session and try import email - is the
email module imported from the stdlib?
If these steps don't help, it might be useful if you can tell us which
Linux distribution you are using.
Cheers,
Kev
> On Thu, Nov 19, 2009 at 5:01 PM, Kev Dwyer <kevin....@gmail.com>
> wrote:
>
>> On Thu, 19 Nov 2009 11:28:37 -0400, Victor Subervi wrote:
>>
>> Hello Victor,
>>
>> There are some pages on the internet that suggest that this problem my
>> be caused by a module named email.py (or email.pyc) in your pythonpath.
>> If you try import smtplib in the interpreter do you get this error
>> message? If so, start a new interpreter session and try import email -
>> is the email module imported from the stdlib?
>>
>>
> Both of these import just fine.
>
>
>> If these steps don't help, it might be useful if you can tell us which
>> Linux distribution you are using.
>>
>>
> Python 2.4.3
> [root@13gems ~]# uname -a
> Linux 13gems.com.13gems.com 2.6.18-028stab064.8 #1 SMP Fri Nov 6
> 11:28:25 MSK 2009 x86_64 x86_64 x86_64 GNU/Linux CentOS 5.4 final
> TIA,
> V
> <div class="gmail_quote">On Thu, Nov 19, 2009 at 5:01 PM, Kev Dwyer
> <span dir="ltr"><<a
> href="mailto:kevin....@gmail.com">kevin....@gmail.com</a>></
span>
> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0
> .8ex;border-left:1px #ccc solid;padding-left:1ex;"> On Thu, 19 Nov 2009
> 11:28:37 -0400, Victor Subervi wrote:<br> <br>
> Hello Victor,<br>
> <br>
> There are some pages on the internet that suggest that this problem my
> be<br> caused by a module named email.py (or email.pyc) in your
> pythonpath. If<br> you try import smtplib in the interpreter do you get
> this error message?<br> If so, start a new interpreter session and try
> import email - is the<br> email module imported from the
> stdlib?<br></blockquote><div><br></div><div>Both of these import just
> fine. </div><blockquote class="gmail_quote" style="margin:0 0 0
> .8ex;border-left:1px #ccc solid;padding-left:1ex;"> <br>
> If these steps don't help, it might be useful if you can tell us
> which<br> Linux distribution you are
> using.<br></blockquote><div><br></div><div>Python
> 2.4.3</div><div><div>[root@13gems ~]# uname -a</div><div>Linux <a
> href="http://13gems.com.13gems.com">13gems.com.13gems.com</a>
> 2.6.18-028stab064.8 #1 SMP Fri Nov 6 11:28:25 MSK 2009 x86_64 x86_64
> x86_64 GNU/Linux</div> <div>CentOS 5.4
> final</div><div>TIA,</div><div>V</div></div></div>
Hello Victor,
I ran your script on a CentOS vm (5.2 server 32bit, not quite the same as
yours but also running python 2.4.3). It ran without error. So I
suspect that either you have a rogue email module/package on your machine
or there's something wrong with the python install.
You could try:
import email
email.__version__
My interpreter responds "3.0.1" If you get a different response that
suggests a dodgy module somewhere - try email.__file__ and see where it's
located (my interpreter returns /usr/lib/python2.4/email/__init__.pyc).
If the version number is "3.0.1" on your machine then I would check the
contents of /usr/lib64/python2.4/email/. Perhaps the base64MIME module
is missing.
Cheers,
Kev
Kevin neglected to mention that the new interpreter session must be
started in the same directory as the one you're in when you run your
testMail.py script. Since he didn't mention that, we can't be sure that
that's what you did, so this experiment doesn't prove anything.
Please show us a copy-and-paste of your command line window contents
that result from executing <<python testMail.py>> and then executing
<<python -c "import email; print email">> immediately thereafter.
Thank you. This proves conclusively that there IS in fact a file called
email.pyc (and/or email.py) in your directory next to testMail.py. It is
this email.pyc that is being imported instead of the email.py from the
Python library. Getting rid of both email.py and email.pyc (by renaming
them, deleting them, or moving them somewhere else) will fix your problem.
Hello Victor,
Carsten's well-specified instruction has identified your problem.
>[root@13gems globalsolutionsgroup.vi]# python -c "import email; print
>email"
><module 'email' from 'email.pyc'>
There is a file named email.pyc, most likely in your current directory,
that is masking the email package in the standard library. Remove/rename
email.pyc and email.py, if it exists.
Cheers,
Kevin