#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    29
    Rep Power
    0

    weird email module problem


    Hi folks,

    this has been working for days then all of a sudden it doesnt

    Code:
    #!/usr/bin/env python
    
    import email, sys
    
    msg = email.message_from_file(sys.stdin)
    
    print msg['from']

    Now its tell me this? WTF

    AttributeError: 'module' object has no attribute 'message_from_file'

    something wierd going on here eh?
  2. #2
  3. onCsdfeu
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Canada
    Posts
    100
    Rep Power
    11
    A simple question : did you upgrade your version of Python ? It seems, from what I've read, that from Python 2.2.1 and above the email module changed. That might be your problem, especially if it stopped suddendly functionning.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    29
    Rep Power
    0
    Hi SolarBear,

    nope didnt upgrade or anything

    only have ever installed python 2.2.3_2 for freebsd and its still whats there.

    its got my beat...
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Hi sissy, try replacing sys.stdin with sys.stdin.read() and see if that helps. It's just one of those strange quirks, somone a little while ago had code that worked on min and stopped another. soon after he got other errors and finally reinstalled Python. What error message are you getting anyway?

    Take care,
    Mark.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    29
    Rep Power
    0
    Hi Mark,

    tried with .read() made no difference also uninstalled and reinstalled python same error, go figure?

    Traceback (most recent call last):
    File "./email.py", line 3, in ?
    import email
    File "./email.py", line 7, in ?
    msg = email.message_from_file(sys.stdin)
    AttributeError: 'module' object has no attribute 'message_from_file'

    kind regards...
  10. #6
  11. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14
    sissy, try this:

    Code:
    tom@tigger tom $ python
    Python 2.2.2 (#1, Dec 15 2002, 20:08:05)
    [GCC 3.2.1] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import email
    >>> dir(email)
    ['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__path__', '__version__', 'message_from_file', 'message_from_string']
    >>>
    To see what's going on with the modue.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    29
    Rep Power
    0
    Hi Telex4,

    well certainly there lies the problem but now the question is how to solve?

    >>> dir(email)
    ['__builtins__', '__doc__', '__file__', '__name__', 'fromaddr', 'line', 'msg', 'prompt', 'server', 'smtplib',]

    so very different,

    thanks
  14. #8
  15. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14
    I have to admit that I haven't the slightest clue! You might try asking this on the newsgroup comp.lang.python where somebody might recognise what module you have. I looked on Google and that certainly wasn't any module I recognise!

    Or you could reinstall just the email module / python to see if it overwrites that module with the "correct" email module?
  16. #9
  17. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69

    self import


    Hey telex, we solved the problem. Apparently the program was importing itself, being named email.py

    Mark.
  18. #10
  19. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14
    Ah you and your private solutions

IMN logo majestic logo threadwatch logo seochat tools logo