PowerCLI

 View Only
Expand all | Collapse all

VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

  • 1.  VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Nov 23, 2022 01:59 AM

    Hello all,

    I have a Win 11 machine running Powershell version 5.1.22621 .  I've loaded (get-module) all relevant PS modules for VMware and am running v13 of VMware.PowerCLI and v8.0.0.2 of VMware.ImageBuilder.

     

    When attempting to create a custom ISO (injecting nvme drivers), I ran the following from an Administrative PowerShell window : Add-EsxSoftwareDepot .\explicit path to the depot .zip file.  This is the error message I receive.  I've not found this on any Google search, DuckDuckGo search, PowerShell site, nor VMware site yet.

     

    Add-EsxSoftwareDepot : Could not initialize the VMware.ImageBuilder PowerCLI module. Make sure that Python 3.7 is
    installed and that you have set the path to the Python executable by using Set-PowerCLIConfiguration -PythonPath. See
    the PowerCLI Compatibility Matrixes for information on the Python requirements.

    While I am unable to find any documentation on that specific "-PythonPath" switch, I have attempted to run it with and without an explicit path to the python executable.  The only one that does not throw an error is to the explicit executable, which is located in C:\Program Files\Python37, so the command looks like : Set-PowerCLIConfiguration -PythonPath "C:\Program Files\Python37\python.exe"

    The result of that operation is :

    Scope ProxyPolicy DefaultVIServerMode InvalidCertificateAction DisplayDeprecationWarnings WebOperationTimeout
    Seconds
    ----- ----------- ------------------- ------------------------ -------------------------- -------------------
    Session UseSystemProxy Multiple Unset True 300
    User
    AllUsers

     

    I even tried an older reference to an environmental command : [Environment]::SetEnvironmentVariable("Path", "$env:Path;c:\Program Files\Python37\python.exe"), which throws no response, or result.

     

    Python 3.7 is installed and can be called from the PowerShell command line : Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32.  I have tried newer versions of Python, but uninstalled, due to the error specifically calling for 3.7.

     

    Python 3.7 is also in the system environmental variables : PATH=C:\Program Files\Python37\Scripts\;C:\Program Files\Python37\

     

    Has anyone experienced this , or is this a new Windows 11, random "feature" haha.  Any help would be immensely appreciated.

    Thanks!!!



  • 2.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Broadcom Employee
    Posted Nov 23, 2022 08:02 AM

    Set-PowerCLIConfiguration -PythonPath "C:\Program Files\Python37\python.exe" seems correct. Do you have the additional Python packages that are pre-requisite for the ImageBuilder module installed in Python 3.7 (six,psutil,lxml,pyopenssl)? It's all described here: https://developer.vmware.com/docs/15315//GUID-9081EBAF-BF85-48B1-82A0-D1C49F3FF1E8.html



  • 3.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Nov 23, 2022 08:55 AM

    I am having the same issue.

    An unexpected error occurred:
    Could not initialize the VMware.ImageBuilder PowerCLI module. Make sure that Python 3.7 is installed and that you have set the path to the Python executable by using Set-PowerCLIConfiguration -PythonPath. See the PowerCLI Compatibility Matrixes for information on the Python requirements.

    I have used the command: Set-PowerCLIConfiguration -PythonPath "C:\Users\*********\AppData\Local\Programs\Python\Python37\python.exe"

    I installed PowerCLI via the command: install-module VMware.PowerCLI
    Powershell is Version : 5.1.19041.610



  • 4.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Broadcom Employee
    Posted Nov 23, 2022 09:22 AM

    And you have installed the additional packages that I've listed above?



  • 5.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Nov 23, 2022 09:49 AM

    So I made the assumption that when installing Python 3.7 all these packages were installed.
    After install six, pyopenssl, psutil, and lxml the problem was solved.

    Thanks!!



  • 6.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Aug 01, 2023 07:41 AM

    Hola saludos cordiales tengo problemas con el powercli y el vmware.imagebuilder no logro hacer que avance a pesar que segui tus paso y logre instalar las herramientas de Python 37 por favor contactame jhon1207@outlook.es



  • 7.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Nov 23, 2022 02:10 PM

    Knikolov,

    Thank you VERY much!  After running : 

    F:\Downloads\VMWARETEMP>python get-pip.py

    and

    C:\Program Files\Python37\Scripts>pip3.7 install six psutil lxml pyopenssl

    I was successfully able to run the Add-EsxSoftwareDepot command.  Now, onto completing the rest of the custom ISO that I'm hoping will permit ESXi to see my nvme controller and attached drives.

    Thanks much!!



  • 8.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Nov 24, 2022 06:54 AM

    I'm having the same issue - could you please elaborate on your steps?

    I've installed Python 3.7 to all users (C:\program files\python37\python.exe)

    1.) Set the Python Path: 

    Set-PowerCLIConfiguration -PythonPath C:\program files\python37\python.exe -Scope User

    2.) pip install six pyopenssl psutil lxml
    3.) Install-Module -Name VMWare.PowerCLI
    4.) Yet when I try '.\VMware-ESXi-8.0-20513097-depot.zip I get the Python path issue:

    Could not initialize the VMware.ImageBuilder PowerCLI module. Make sure that Python 3.7 is
    installed and that you have set the path to the Python executable by using Set-PowerCLIConfiguration -PythonPath. See
    the PowerCLI Compatibility Matrixes for information on the Python requirements.

    I've tried both a local Windows 7 box and a Windows 2019 remote machine in the hopes that my local machine was the issue. Both don't work.



  • 9.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Broadcom Employee
    Posted Nov 24, 2022 09:43 AM

    Can you do Get-PowerCLIConfiguration | select * to make sure that the path is set correctly. 

    Also if you have more than one python version are you sure that you have run pip install on the correct one. 



  • 10.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Nov 24, 2022 01:31 PM

    I think Knikolov is onto something - looking at your pip command, you used the one without 3.7 - try running that command again as pip3.7.exe, not the pip.exe.



  • 11.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Nov 28, 2022 11:21 PM

    I have the same problem, checked the install directory and its correct. Tried installing dependencies with pip3.7, all did not help

    Keep getting:

    Could not initialize the VMware.ImageBuilder PowerCLI module. Make sure that Python 3.7 is installed and that you have set the path to the Python executable by using Set-PowerCLIConfiguration -PythonPath.

    Tried to install Python using Chocolatey, didn't help. I'm a bit lost now, any new hint ais more than welcome.  



  • 12.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Broadcom Employee
    Posted Nov 29, 2022 12:42 PM

    There is a more detailed log of the python code initialization that is located in the temp folder in a file called if-server.log<some number>. Can you please attach this file, so that we can take a more detailed look at it?



  • 13.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Nov 29, 2022 06:41 PM

    Preventing that it was something with the machine I'm working on, I installed everything on a different computer today. Same problem, and then it struck me..... A Helpdesk 1.0....... DID YOU RESTART YOUR COMPUTER.....euhhhhhh.......ooooppsssss.......



  • 14.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Dec 02, 2022 08:40 AM

    This is the winning comment!

    You need to do everything in my previous post above, and THEN reboot (to get rid of those pesky Python errors).

    This was also pretty helpful in building a custom ISO without having access to vCenter:
    https://github.com/sh1njp/esxi7_custom



  • 15.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Broadcom Employee
    Posted Dec 02, 2022 01:08 PM

    Are you sure that a reboot of the machine is required? Isn't it enough just to restart PowerShell?



  • 16.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Dec 02, 2022 08:55 PM

    There must be something else in what I did

    I did want to make sure if this was the solution, so I did a clean install Win11 in VMworkstation, followed all steps, but no luck. Getting the same Python 3.7 error again......



  • 17.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Dec 04, 2022 11:44 PM

    Hey man I finally just solved this issue. For me I had to update pip with python -m pip install --upgrade pip and then use the pip3.10.exe to install the four packages. From here I went back to esxi installation and it worked error free



  • 18.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Broadcom Employee
    Posted Dec 05, 2022 09:27 AM

    Yes, updating pip is an alternative to downloading it again, which is the proposed solution in the official documentation.

    Btw I found this blog post quite useful in explaning the thing in more detail: https://blog.zuthof.nl/2022/11/30/powercli-13-update-and-installation-hurdles-on-windows/.



  • 19.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Jan 15, 2023 07:24 PM

    This post fixed it for me, really appreciate it 



  • 20.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Mar 13, 2023 12:10 AM

    It worked for me too.

    I followed all the steps here, installed the 4 additional packages and it didn't work.

    I closed PowerShell, repeated the steps again, restarted powershell, and it didn't work.

    So I closed PowerShell, followed all the steps again, restarted the computer and voilá, all right.

    I think anyone with this problem is worth following all the guidelines in this topic and restarting the machine.

    Wow, hugs!!



  • 21.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Nov 26, 2022 08:59 AM

    i have another problem when i try to install ( pip install lxml )

    pip install lxml
    Collecting lxml
    Using cached lxml-4.9.1.tar.gz (3.4 MB)
    Preparing metadata (setup.py): started
    Preparing metadata (setup.py): finished with status 'done'
    Building wheels for collected packages: lxml
    Building wheel for lxml (setup.py): started
    Building wheel for lxml (setup.py): finished with status 'error'
    pip : error: subprocess-exited-with-error
    At line:1 char:1
    + pip install lxml
    + ~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: ( error: subprocess-exited-with-error:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError



  • 22.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Dec 05, 2022 12:33 PM

    I used another solution, which was to install python 3.7 in the Microsoft Store (I checked it was version 3.7.9 after installation), which solved that problem, but then other problems came up. For the time being, it is not solved.



  • 23.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Dec 05, 2022 02:53 PM

    Can we move this thread to the PowerCLI Community?
    It contains important information, and I guess it could be more useful in the PowerCLI Community.



  • 24.  RE: VMWare.Imagebuilder has issue with Python 3.7 and running Add-EsxSoftwareDepot

    Posted Mar 16, 2023 09:02 AM

    Hi all,

    I came across this post while trying to make my own custom ISO for ESXi 6.7 and add a NIC driver (r8168).

    After hours of trying and failing with different errors in PowerCLI i found the Image Builder in vCenter that worked a treat and took about 10 minutes from enabling to having my custom ISO ready.

    Great article here how to get it done, highly reccommend against trying to battle with PowerCLI

    https://4sysops.com/archives/using-esxi-iso-image-builder-with-vmware-vsphere-70-update-2/

    Hope this helps someone.

    Thanks

    Mike