VMware Cloud Community
Matrices07
Contributor
Contributor

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

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!!!

23 Replies
knikolov
VMware Employee
VMware Employee

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

nielsgeursen
Enthusiast
Enthusiast

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

Reply
0 Kudos
knikolov
VMware Employee
VMware Employee

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

Reply
0 Kudos
nielsgeursen
Enthusiast
Enthusiast

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!!

Reply
0 Kudos
Matrices07
Contributor
Contributor

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!!

Reply
0 Kudos
jeromeza
Contributor
Contributor

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.

Reply
0 Kudos
knikolov
VMware Employee
VMware Employee

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. 

Matrices07
Contributor
Contributor

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.

pashewwshiar
Contributor
Contributor

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

Reply
0 Kudos
Jerry7532
Contributor
Contributor

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.  

Reply
0 Kudos
knikolov
VMware Employee
VMware Employee

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?

Reply
0 Kudos
Jerry7532
Contributor
Contributor

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.......

Spoiler
NOOOOO!!!!!!!
Reply
0 Kudos
jeromeza
Contributor
Contributor

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

Reply
0 Kudos
knikolov
VMware Employee
VMware Employee

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

Jerry7532
Contributor
Contributor

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......

Reply
0 Kudos
cadenus
Contributor
Contributor

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

Reply
0 Kudos
knikolov
VMware Employee
VMware Employee

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/.

ziznah
Contributor
Contributor

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.

Reply
0 Kudos
LucD
Leadership
Leadership

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos