python-2.7vsphereesxiesxpyvmomi

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


I am playing arround with pyvmomi and I managed to get the "sample" script (getallvms.py) working.

I am now trying an other script that I found here: https://raw.githubusercontent.com/vmware/pyvmomi-community-samples/master/samples/vminfo_quick.py

When I run this script I get the following error:

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

I am not sure how I install the module "tools". Can someone tell me how I should continue?

Thanks, Iwan


Solution

  • The script you are trying to run is meant to be run from the samples project directory. To have the most success you would want to clone the project:

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

    Once you do that the import issues will go away. If you look in the samples directory you will find tools/cli which is what is trying to be imported.