Sunday 30 June 2019

How to Install Python 2.7.12 to run ESXi Learnswitch in Windows


1) Download ESXi Learnswitch using the below link:

2) Download python 2.7.12 using the below link: ( 32bit) works fines in 64bit machines.

3) Download winscp using the below link:

4) Download Putty using the below link:

5) Download yaml using the below link:

6) Download six for python using the below link:


PART 1: Installing ESXi Learnswitch vib file on Physical ESXi Server.

1) To get started Download the utility from the following link " ESXi Learnswitch"

2)  The next step is to install the vib file on the ESXi Server that is included as part of the ESXi

3)  Extract the "ESXi-Learnswitch-v1.0.1" into a folder on your computer and copy the "VMware-ESXi-6.5.0-5556125-learnswitch" or "VMware-ESXi-6.0.0-5555972-learnswitch" using WINSCP into the tmp folder on the ESXi Server based on the version of Physical ESXi you are running in your infrastructure.

4) The below screenshot shows that I have copied the "VMware-ESXi-6.5.0-5556125-learnswitch" to a folder on my ESXi Server.

5)  Start a putty session to your physical ESXi Server and execute the below command to install the vib file.In my case since, I have already installed the vib, the below screenshot shows "VIBs Installed" as blank, but if you are installing for the first time, you should see the "VMware_bootbank_esx-learnswitch_6.5.0-1.26.5556125" next to it. Once done, reboot the ESXi Server.

# esxcli software vib install -d /

Note: If you installed the VIB on an ESXi 6.0 system and you plan to upgrade to ESXi 6.5, make sure you uninstall the VIB before installing the 6.5 VIB.

PART 2: Installing Python 2.7.12 on Windows 10 machine.

6)  Use the below link to download Python 2.7.12 for the operating system you are running. In my case, I am running windows 10, hence I downloaded the "Windows x86 MSI installer".

7) Use the below screenshots for reference during Installation.

8)  The next step validates that Python has been successfully installed and is added to the path of the command line.

9) We now need the Python config file and the "VMware-pyVpx-6.5.0-4602587" file from the "ESXi Learnswitch-v1.0.1" zip file for the next steps.

10) Extract the "VMware-pyVpx-6.5.0-4602587" into a folder and move the "learnswitch_cfg" into the "pyVpx" folder that was extracted as below.

11) We need to edit the "learnswitch_cfg" and udpate the details of our vCenter SSO admin username and password under "vc_user" and "vc_password". Then update the  Distributed portgroups where the nested ESXi VMs will run under "dvpg_name_list", the below section is what you need to modify.Once done save the file and exit.

12) Follow the steps under "ISSUES and FIXES" in the order mentioned below:
a) Remove "Import pwd" from the script.
b) Installing yaml for python 2.7.12.
c) Installing Six for python 2.7..

13) Now use the command line and cd into the folder of the script and execute the below command, my lab environment details is a below:

vCenter IP : 192.168.A.B

ESXi IP :  192.168.C.D


# python 192.168.A.B PROD-PHY-DVSWITCH 192.168.C.D add
13) You command should now be a success.


1) Remove "Import pwd" from the script.

ERROR MESSAGE: Traceback (most recent call last):
  File "", line 21, in <module>
    import pwd
ImportError: No module named pwd

FIX: Open the learnswitch_cfg using notepad and find the below line and delete it as below.Save the file and exit.

2) Installing yaml for python 2.7.

ERROR MESSAGE: Traceback (most recent call last):
  File "", line 25, in <module>
    import yaml
ImportError: No module named yaml

FIX: a) Use the below link and download 32bit Installers for Python 2.7

b) Once downloaded copy the "PyYAML-5.1-cp27-cp27m-win32.whl" file to your python directory as below and execute the command:

# pip install PyYAML-5.1-cp27-cp27m-win32.whl

3) Installing Six for python 2.7.

ERROR MESSAGE:   C:\PYTHON_SCRIPTS\ESXi-Learnswitch-v1.0.1\VMware-pyVpx-6.5.0-4602587\pyVpx>python 192.168.A.B PROD-PHY-DVSWITCH 192.168.C.D add
Traceback (most recent call last):
  File "", line 28, in <module>
    from pyVim.task import WaitForTask
  File "C:\PYTHON_SCRIPTS\ESXi-Learnswitch-v1.0.1\VMware-pyVpx-6.5.0-4602587\pyVpx\pyVim\", line 18, in <module>
    from pyVmomi import Vmodl, Vim
  File "C:\PYTHON_SCRIPTS\ESXi-Learnswitch-v1.0.1\VMware-pyVpx-6.5.0-4602587\pyVpx\pyVmomi\", line 13, in <module>
    from . import VmomiSupport
  File "C:\PYTHON_SCRIPTS\ESXi-Learnswitch-v1.0.1\VMware-pyVpx-6.5.0-4602587\pyVpx\pyVmomi\", line 6, in <module>
    from . import Iso8601
  File "C:\PYTHON_SCRIPTS\ESXi-Learnswitch-v1.0.1\VMware-pyVpx-6.5.0-4602587\pyVpx\pyVmomi\", line 9, in <module>
    import six
ImportError: No module named six

FIX: a) Use the below link to download and install six package from the below link.

b) Copy the downloaded "six-1.12.0-py2.py3-none-any.whl" file to the python folder and execute the below command to install.

# pip install six-1.12.0-py2.py3-none-any.whl

No comments: