Registry / devops / pyvmomi

pyvmomi

JSON →
library9.1.0.0pypypi✓ verified 25d ago

pyVmomi is the Python SDK for the VMware vSphere Management API, enabling developers to build solutions integrated with VMware ESXi and vCenter Server. It provides Python bindings for several SOAP-based vSphere APIs, including core VIM API and related extensions like ESX Agent Manager and Storage Policy API. While pyVmomi focuses on SOAP APIs, the vSphere Automation SDK for Python is recommended for REST API features. pyVmomi releases often correlate with vSphere major versions and maintain backward compatibility with the previous four vSphere releases and its own previous four releases.

pip install --upgrade pyvmomi
INSTALL
IMPORT
SIG · PYVMOMI
P
pyvmomi
devopspythonv9.1.0.0
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v9.1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
1/2 runs
1/2 runs
py 3.11
1/2 runs
1/2 runs
py 3.12
1/2 runs
1/2 runs
py 3.13
1/2 runs
1/2 runs
py 3.9
1/2 runs
1/2 runs
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SmartConnect
from pyVim.connect import SmartConnect, Disconnect
from pyVim.connect import SmartConnectNoSSL
SmartConnectNoSSL is deprecated; it's better to manage SSL context explicitly with SmartConnect.
vim
from pyVmomi import vim
VmomiJSONEncoder
from pyVmomi.VmomiJSONEncoder import VmomiJSONEncoder
from pyVmomi.VmomiSupport import VmomiJSONEncoder
Path changed in pyvmomi 9.0.0.0.
templateOf
from pyVmomi.VmomiJSONEncoder import templateOf
from pyVmomi.VmomiSupport import templateOf
Path changed in pyvmomi 9.0.0.0.
ThumbprintMismatchException
from pyVmomi.Security import ThumbprintMismatchException
from pyVmomi import ThumbprintMismatchException
Path changed in pyvmomi 9.0.0.0.

This quickstart demonstrates how to connect to a vCenter Server, retrieve its content, and list all virtual machines using pyVmomi. It includes common practices like handling SSL contexts and using environment variables for credentials.

import ssl import os from pyVim.connect import SmartConnect, Disconnect from pyVmomi import vim # Environment variables for credentials and host VCENTER_HOST = os.environ.get('VCENTER_HOST', 'your_vcenter_ip_or_fqdn') VCENTER_USER = os.environ.get('VCENTER_USER', 'your_username') VCENTER_PASS = os.environ.get('VCENTER_PASS', 'your_password') if VCENTER_HOST == 'your_vcenter_ip_or_fqdn' or VCENTER_USER == 'your_username' or VCENTER_PASS == 'your_password': print("Please set VCENTER_HOST, VCENTER_USER, and VCENTER_PASS environment variables or update the script.") exit(1) def main(): service_instance = None context = None try: # Disable SSL certificate verification for labs/testing. NOT recommended for production. context = ssl._create_unverified_context() print(f"Connecting to vCenter: {VCENTER_HOST}...") service_instance = SmartConnect(host=VCENTER_HOST, user=VCENTER_USER, pwd=VCENTER_PASS, sslContext=context) content = service_instance.RetrieveContent() print(f"Connected to vCenter: {content.about.fullName}") # Retrieve all virtual machines container = content.viewManager.CreateContainerView(content.rootFolder, [vim.VirtualMachine], True) vms = container.view print("\nVirtual Machines:") if not vms: print("No virtual machines found.") for vm in vms: print(f" Name: {vm.name}, Power State: {vm.runtime.powerState}") container.Destroy() except Exception as e: print(f"Error: {e}") finally: if service_instance: print("Disconnecting from vCenter.") Disconnect(service_instance) if __name__ == '__main__': main()
Debug
Known issues
breakingpyVmomi 9.0.0.0 introduced several breaking changes including the removal or replacement of `SoapAdapter` connection classes, aliases like `publicVersions` and `dottedVersions`, and changes to the module paths for `VmomiJSONEncoder`, `templateOf()`, and `ThumbprintMismatchException`.
fix
Review the pyVmomi 9.0.0.0 release notes for specific class and alias changes. Update import paths and method calls as detailed in the official documentation or the `imports` section of this registry entry. For example, `pyVmomi.VmomiSupport.VmomiJSONEncoder` moves to `pyVmomi.VmomiJSONEncoder.VmomiJSONEncoder`.
affects: 9.0.0.0 and later
breakingThe `six` dependency has been removed, and the `pyOpenSSL` dependency is now limited to '<24.3.0' in pyVmomi 9.0.0.0 due to breaking changes in pyOpenSSL.
fix
Ensure your environment meets the updated dependency requirements. If you were relying on `six` directly, update your code to use Python 3 native constructs. Pin `pyOpenSSL` to a compatible version if issues arise.
affects: 9.0.0.0 and later
deprecatedThe `b64token` and `mechanism` parameters for `pyVim.Connect()` and `pyVim.SmartConnect()` have been disabled in pyVmomi 9.0.0.0. They are replaced by `token` and `tokenType`.
fix
Update your connection calls to use `token` and `tokenType` parameters for SSO authentication, as described in the official vSphere SDK documentation.
affects: 9.0.0.0 and later
gotchaConnecting to vCenter or ESXi with untrusted (self-signed) SSL certificates will fail by default in modern Python versions.
fix
For development or non-production environments, create an unverified SSL context: `context = ssl._create_unverified_context()` and pass it to `SmartConnect(sslContext=context)`. For production, import and verify the vCenter's SSL certificate.
affects: All versions with Python 2.7.9+ or Python 3.x
gotchapyVmomi is designed for the vSphere Management API (SOAP-based). For newer vSphere Automation APIs (REST-based), you should use the `VMware vSphere Automation SDK for Python` instead.
fix
Determine whether you need to interact with SOAP-based Management APIs or REST-based Automation APIs. If the latter, switch to `vsphere-automation-sdk-python` for appropriate functionality.
affects: All versions
gotchapyVmomi maintains backward compatibility with the previous four releases of vSphere and its own previous four releases. Using it with significantly older or very new, unsupported vSphere versions may lead to unexpected behavior or missing features.
fix
Always check the official pyVmomi compatibility matrix against your vSphere environment version to ensure support and expected behavior.
affects: All versions (compatibility policy)
Upgrade
Version history
9.1.0.0latest on PyPI · released May 12, 2026
Audit
Dependencies
pyOpenSSLrequiredRequired for SSL operations; version limited to '<24.3.0' in pyvmomi 9.0.0.0 due to breaking changes in pyOpenSSL.
Agent activity
12 hits · last 30 days
node
10
Resources
pyvmomi — pip install pyvmomi · libregistry