4

I am attempting to run the following code which I received from samples here

from __future__ import print_function
import atexit
from pyVim.connect import SmartConnectNoSSL, Disconnect
from pyVmomi import vim
from tools import cli

I am receiving the following error:

ModuleNotFoundError: No Module named 'pyVim.connect'

The packages in question are from here and were installed using:

pip install pyvmomi

Is there something wrong with how I am installing these packages?

Trevor Jordy
  • 598
  • 1
  • 7
  • 27

3 Answers3

5

Looks like the code was a bit old. Importing 'pyvim' instead of 'pyVim' worked, though it seems to be named 'pyVim' on the github.

Trevor Jordy
  • 598
  • 1
  • 7
  • 27
4

It's possible that you need to reinstall pvmomi to force the re-install of additional files in the pyVim/ package dir:

pip3 install --force pyvmomi
Brian Cunnie
  • 353
  • 2
  • 9
3

I haven't figured out how or what causes this, but the issue seems to occur on case-insensitive macOS file systems.

Since it has different behavior than Linux and case-sensitive macOS, I use the following "hack" to make it compatible between systems:

try:
    from pyVim.connect import SmartConnectNoSSL
except ImportError:
    from pyvim.connect import SmartConnectNoSSL

PS: You can use diskutil info / on macOS to figure out if your file system is case-sensitive or not (Details in another StackExchange question)

intgr
  • 19,834
  • 5
  • 59
  • 69