Error when I try to execute a script: ImportError: No module named tools

Error when I try to execute a script: ImportError: No module named tools

我正在玩 pyvmomi,我设法使 "sample" 脚本 (getallvms.py) 正常工作。

我现在正在尝试在此处找到的其他脚本: https://raw.githubusercontent.com/vmware/pyvmomi-community-samples/master/samples/vminfo_quick.py

当我 运行 这个脚本时,我得到以下错误:

Iwans-Mac:sample iwan-home-folder$ python vminfo_quick.py -s 10.11.11.215 -u pyvmomi-user@sso-iwan.local -p VMware1!

Traceback (most recent call last):
  File "vminfo_quick.py", line 19, in <module>
    from tools import cli
ImportError: No module named tools

我不确定如何安装模块 "tools"。 谁能告诉我应该如何继续?

谢谢, 伊万

您尝试 运行 的脚本应该是来自示例项目目录的 运行。要获得最大的成功,您需要克隆该项目:

git clone https://github.com/vmware/pyvmomi-community-samples
cd pyvmomi-community-samples/samples
python vminfo_quick.py xxxx

一旦您这样做,导入问题就会消失。如果您查看示例目录,您会发现 tools/cli 这是试图导入的内容。