I am trying to read a mail , which has html content in it. I am using message_from_bytes to read the data from mail.
def ParseEmail(email_user,email_pass,host,port,pdf):
    message_list = []
    mail = imaplib.IMAP4_SSL(host, port)
    mail.login(email_user, email_pass)
    mail.select()
    typ, data = mail.search(None, 'unseen')
    mail_ids = data[0]
    id_list = mail_ids.split()
    for num in id_list:
        typ, data = mail.fetch(num, '(RFC822)')
        raw = email.message_from_bytes(data[0][1])
        raw_email = data[0][1]
        raw_email_string = raw_email.decode('utf-8')
        email_message = email.message_from_string(raw_email_string)
        soup = BeautifulSoup(get_body(raw))
        content = soup.get_text('\n').replace('\xa0:\n\xa0\n', ' ')
        message_list.append(content)
the code compiles and runs without any error. when checked with IPython console, the message_list array is also printed. but, when I call this through driver functions I am getting error:
Traceback (most recent call last):
  File "parseemail.py", line 395, in <module>
    main()
  File "/Users/test/dev/Email/parseemail.py", line 384, in main
    pe = ParseEmail(email_user, email_pass, host, port,pdf)
  File "/Users/test/dev/Email/parseemail.py", line 320, in ParseEmail
    raw = email.message_from_bytes(data[0][1])
AttributeError: 'module' object has no attribute 'message_from_bytes'
what could br the possible error? (All the packages are installed and tested).
