Discussion:
ModuleNotFoundError: No module named 'email.mime'; 'email' is not a package
(too old to reply)
b***@bbhoyer.com
2019-12-08 19:13:26 UTC
Permalink
Just registered 
Thanks

-------- Original Message --------
Subject: ModuleNotFoundError: No module named 'email.mime'; 'email' is
not a package
From: <[1]***@bbhoyer.com>
Date: Sun, December 08, 2019 11:14 am
To: [2]python-***@python.org

Hello Python Team, 
I am a beginner in Python, been working on class material from Mosh
youtube 6 hrs., Mosh 12 hr paid course; Python Cash Course by Eric
Matthes  … most of the time everything works just fine or a little
adjustment for updated versions.
I am running Python 3.8.0 
In example, Mosh 12 hr course, he did an exercise on sending email from
within Python, so here is the code :
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib
message = MIMEMultipart()
message["from"] = "Bob Hoyer = Python"
message["to"] = "[3]***@bbhoyer.com"
message["subject"] = "This is a test using Python"
message.attach(MIMEText("Body"))
# godaddy recommended SMTP_SSL, host name & port #
with smtplib.SMTP(host="smtpout.secureserver.net", port=465) as smtp:
    smtp.ehlo()
    # godaddy recommended removing ...
    # smtp.starttls()
    smtp.login("[4]***@email.com", "password")  #email login &
password blanked out for this msg
    smtp.send_message(message)
    print("Sent ...")
smtp.close()
Here is the error message: 
Traceback (most recent call last):
  File "c:\Users\Owner\Desktop\HelloWorld\[5]email.py", line 1, in <module>
    from email.mime.multipart import MIMEMultipart
  File "c:\Users\Owner\Desktop\HelloWorld\[6]email.py", line 1, in <module>
    from email.mime.multipart import MIMEMultipart
ModuleNotFoundError: No module named 'email.mime'; 'email' is not a package
I have spent some time trying to figure out resolve ...
Can you help me with this pistol of a problem … 
Bob Hoyer

References

Visible links
1. mailto:***@bbhoyer.com
2. mailto:python-***@python.org
3. mailto:***@bbhoyer.com
4. mailto:***@email.com
5. http://email.py/
6. http://email.py/
MRAB
2019-12-08 22:18:14 UTC
Permalink
Post by b***@bbhoyer.com
Just registered
Thanks
-------- Original Message --------
Subject: ModuleNotFoundError: No module named 'email.mime'; 'email' is
not a package
Date: Sun, December 08, 2019 11:14 am
Hello Python Team,
I am a beginner in Python, been working on class material from Mosh
youtube 6 hrs., Mosh 12 hr paid course; Python Cash Course by Eric
Matthes  … most of the time everything works just fine or a little
adjustment for updated versions.
I am running Python 3.8.0
In example, Mosh 12 hr course, he did an exercise on sending email from
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib
message = MIMEMultipart()
message["from"] = "Bob Hoyer = Python"
message["subject"] = "This is a test using Python"
message.attach(MIMEText("Body"))
# godaddy recommended SMTP_SSL, host name & port #
    smtp.ehlo()
    # godaddy recommended removing ...
    # smtp.starttls()
password blanked out for this msg
    smtp.send_message(message)
    print("Sent ...")
smtp.close()
  File "c:\Users\Owner\Desktop\HelloWorld\[5]email.py", line 1, in <module>
    from email.mime.multipart import MIMEMultipart
  File "c:\Users\Owner\Desktop\HelloWorld\[6]email.py", line 1, in <module>
    from email.mime.multipart import MIMEMultipart
ModuleNotFoundError: No module named 'email.mime'; 'email' is not a package
I have spent some time trying to figure out resolve ...
Can you help me with this pistol of a problem …
Bob Hoyer
[snip]
I notice you have files called "[5]email.py" and "[6]email.py". Do you
also have one called "email.py"?

If so, then what's happening is that Python is finding that one before
the one in the stdlib.
DL Neil
2019-12-08 22:34:31 UTC
Permalink
Post by b***@bbhoyer.com
Just registered
Thanks
I am a beginner in Python, been working on class material from Mosh
...
Post by b***@bbhoyer.com
from email.mime.multipart import MIMEMultipart
...
Post by b***@bbhoyer.com
  File "c:\Users\Owner\Desktop\HelloWorld\[5]email.py", line 1, in <module>
    from email.mime.multipart import MIMEMultipart
  File "c:\Users\Owner\Desktop\HelloWorld\[6]email.py", line 1, in <module>
    from email.mime.multipart import MIMEMultipart
ModuleNotFoundError: No module named 'email.mime'; 'email' is not a package
I have spent some time trying to figure out resolve ...
Can you help me with this pistol of a problem …
("pistol"? ...he says, manfully-struggling with the temptation to
suggest that you "make love not war"...)


Let's look at the information given (in the "stack trace":

<<<ModuleNotFoundError: No module named 'email.mime'; 'email' is not a
package>>>

On line 1, the code requests that a module named/addressed as
"email.mime.multipart" be located ("found"), and an object
("MIMEMultipart") be imported (etc, etc).

So, when executing line 1, Python was unable to find the specified
module (let's over-simplify and use the word: "file").


Libraries from the Python Standard Library are not included in the basic
"python" download, and have to be added/separately downloaded, when
needed. I suspect this is the problem (but may not be)!


Sadly, I am not a user of MS-Win, so am loath to try to help much more,
for fear of leading you along the wrong track. Herewith some self-study
which should put your boots (back) on the ground...


WebRefs: installing packages
This is more readable:
https://protechguides.com/how-to-install-python-library/
This is from 'the book of words':
https://packaging.python.org/tutorials/installing-packages/

NB I understand that "pip" is installed on MS-Win as part of python, so
you don't need to worry about that/can quickly check. If your course has
not taken you through "virtual environments" then feel free to ignore
such, for now.
--
Regards =dn
Loading...