Installing correct Python version for VMware PowerCLI 13 ImageBuilder for ESXi 8 custom images

This quick post outlines the successful approach for installing Python on Windows in order to use PowerCLI for making a custom ESXi 8 image.

As you’ll know already this requires PowerCLI 13 as a minimum to be able to handle ESXi8 images, however try as I might there were persistent problems installing and configuring Python on my Windows 10 VM (caused by failure to recognise OpenSSL mainly).

Here’s what I know, having been through several troubleshooting steps:

  • You don’t need to install OpenSSL separately, this is distributed in the pyopenssl package installed by Pip
  • The -pythonpath parameter in the Set-PowerCLIConfiguration commandlet needs to include python.exe and be surrounded by double-quotes if necessary
  • You can run pip commands from command prompt or PowerShell, but the VMware instructions have you run the versioned command e.g. pip3.11.exe from within the Python installation

Python 3.12.3 did not work with PowerCLI 13.2.1, even when using the process outlined below. It would never detect the correct version of OpenSSL. I was only able to make Python 3.11.9 work successfully with this release of PowerCLI.

Here is a brief outline of what I did in order to resolve my problems – I feel that starting on a fresh installation was important here.

Outline of installation steps

Built a clean VM in Azure running Windows 11, this was an important point to eliminate any problems which might have been caused by upgrading from previous PowerCLI versions.

Opened PowerShell 5.1, this is pre-installed with Windows and so there is no need to install

$PSVersionTable.PSVersion

Major Minor Build Revision
----- ----- ----- --------
5 1 22621 2506

Installed PowerCLI using

Install-Module VMware.PowerCLI -Scope CurrentUser

Installed Python installer for Windows (https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe) from https://www.python.org/downloads/release/python-3119/ and deliberately installed it for ‘all users’ using an administrator privileged installation.

The newer versions include the Pip package manager so it’s not necessary to use the later ‘get-pip.py’ script to install the additional packages, these can be obtained without it.

Return to Powershell window and configured the Python path, noting that there are double quotes around the value because of a space character in ‘Program Files’.

Set-PowerCLIConfiguration -PythonPath "C:\Program Files\Python311\python.exe" -Scope User

Based upon the general instructions here: https://developer.vmware.com/docs/15315/GUID-F98FF88D-D31F-48F0-8C3A-1C6492CD8AFB.html

It was then straight forward to install the necessary additional packages via command line (I used Windows Command Prompt)

cd "C:\Program Files\Python311\Scripts"
pip3.11.exe install six psutil lxml pyopenssl

Close Command Prompt and PowerShell, then reopen PowerShell. Test the ability of ImageBuilder to access the Python packages it needs by using:

Get-EsxImageProfile

This command will generate a red error in PowerShell if any of the elements are missing, but don’t be too quick in reading the output as there are several different errors which all start with similar beginnings.

Building custom ESXi image – additional material

Here are some example commands for what you might do next once PowerCLI and Python are working properly. The process here shows what you would do in order to install the VMware Fling for the USB network driver into an ESXi 8.0U2b generic offline depot file.

Only two files are referenced here, ESXi80U2-VMKUSB-NIC-FLING-67561870-component-22416446.zip and VMware-ESXi-8.0U2b-23305546-depot.zip which can be obtained from the VMware Flings page and VMware Customer Connect portal.

Make sure you log in first to access the Flings page otherwise none of the download options will be visible.

Once the .ISO file is generated then you can use a tool like Rufus to write the image to a bootable USB drive for instance.

Add-EsxSoftwareDepot .\ESXi80U2-VMKUSB-NIC-FLING-67561870-component-22416446.zip
Add-EsxSoftwareDepot .\VMware-ESXi-8.0U2b-23305546-depot.zip

Get-EsxSoftwareDepot | fl

Depot Url
---------
zip:C:\Users\vmadmin\Downloads\ESXi80U2-VMKUSB-NIC-FLING-67561870-component-22416446.zip?index.xml
zip:C:\Users\vmadmin\Downloads\VMware-ESXi-8.0U2b-23305546-depot.zip?index.xml

Get-EsxImageProfile | ft Name

Name
----
ESXi-8.0U2b-23305546-standard
ESXi-8.0U2sb-23305545-standard
ESXi-8.0U2b-23305546-no-tools
ESXi-8.0U2sb-23305545-no-tools

Get-EsxSoftwarePackage -Name *usb*

Name Version Vendor Creation Date
---- ------- ------ -------------
vmkusb-nic-fling 1.12-2vmw.802.0.0.67561870 VMW 9/7/2023 8:53...
vmkusb 0.1-18vmw.802.0.0.22380479 VMW 9/4/2023 9:34...
vmkusb-esxio 0.1-18vmw.802.0.0.22380479 VMW 9/4/2023 9:33...

New-EsxImageProfile -CloneProfile "ESXi-8.0U2b-23305546-standard" -Name "ESXi-8.0U2b-23305546-standard-usb-fling" -vendor "VMware"

Name Vendor Last Modified Acceptance Level
---- ------ ------------- ----------------
ESXi-8.0U2b-23305546-standa... VMware 2/29/2024 12... PartnerSupported

Add-EsxSoftwarePackage -ImageProfile "ESXi-8.0U2b-23305546-standard-usb-fling" -SoftwarePackage "vmkusb-nic-fling" -Force

Export-EsxImageProfile -ImageProfile "ESXi-8.0U2b-23305546-standard-usb-fling" -FilePath "VMware-ESXi-8.0U2b-23305546-USB-NICs.iso" -ExportToIso -Force

Leave a Reply