0%

ImportError: No module named mime.text

一个python脚本执行报错,老版本python中MIMEText 写法不对

1
2
3
4
5
6
7
8
[root@localhost:~]# /usr/bin/python check_linux_resource.py
Traceback (most recent call last):
File "/usr/local/mysqlmtop/global_functions.py", line 11, in ?
from email.mime.text import MIMEText
ImportError: No module named mime.text

[root@localhost:~]# /usr/bin/python -V
Python 2.4.3
1
2
from email.mime.text import MIMEText
from email.header import Header

将以上写法修改为下面这样就ok

1
2
from email.MIMEText import MIMEText
from email.Header import Header