Python2.5、smtplib和KeyError
我正在尝试为 ESXi 上的 BusyBox 编写一个具有邮件功能的 python 脚本。它运行Python 2.5,但缺少一些库(即smtplib)。我下载了 Python2.5 源代码并将 lib 文件夹复制到 ESXi。现在我尝试通过“import lib.smtplib”导入 smtplib,但 Python 说:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/pysexi/lib/smtplib.py", line 46, in <module>
import email.Utils
File "/pysexi/lib/email/__init__.py", line 115, in <module>
setattr(sys.modules['email'], _name, importer)
KeyError: 'email'
我被卡住了。因此,我们非常感谢每一个帮助和每一个想法!
I'm trying to write a python script for BusyBox on ESXi with mail functionality. It runs Python 2.5 with some libraries missing (i.e. the smtplib). I downloaded Python2.5 sources and copied the lib-folder to ESXi. Now I am trying to import the smtplib via "import lib.smtplib" but Python says:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/pysexi/lib/smtplib.py", line 46, in <module>
import email.Utils
File "/pysexi/lib/email/__init__.py", line 115, in <module>
setattr(sys.modules['email'], _name, importer)
KeyError: 'email'
I'm stuck. So every help and every thought is appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在设备或自定义操作系统上安装通用应用程序总是很有趣。
只是一个猜测,但电子邮件库可能是一个编译的 C 模块 - 即不是纯 python。
我会尝试使用完全 python 的库,没有编译代码 - 我不知道是否有纯 python 版本的库。
该选项是尝试跟踪 ESXi 基于的操作系统版本,然后使用该操作系统中匹配的 python 版本。
Trying to install generic applications on an appliance or custom OS is always fun.
Just a guess, but it may be that the email lib is a compiled C module - i.e. not pure python.
I would try use libraries that are as completely python with no compiled code - I don't know if there are pure python versions of the libraries.
The option is to try to track down what OS version that ESXi is based on and then use the matching python version from that OS.
我对 BusyBox 或 ESXi 一无所知 - 因此这可能更多的是建议而不是答案,但您可能会考虑使用支持 HTTP 或 RESTful API 的电子邮件服务 - 例如 MailGun。他们有一个免费计划,每天最多可发送 200 封电子邮件,因此可能不需要您支付任何费用。
再次强调,这种方式更多的是一种建议或“B”计划(如果没有人可以帮助您解决这个具体问题)
I don't know anything about BusyBox or ESXi - therefore this may be more of a suggestion than an answer, but you might consider using a email service that supports an HTTP or RESTful API - such as MailGun. They have a free plan for up to 200 emails a day, so it might not cost you anything.
Again, this way be more of a suggestion or a plan "B" (if no one can help you with this specific problem)