Setting up pyvmomi with pyenv and pipenv

Posted by

In this post I’ll show how to set up a pyvmomi environment using modern Python tools such as pipenv. pyvmomi wasn’t difficult to setup before but it’s much easier now that the pyvmomi maintainers have taken a more modern approach to managing the pyvmomi distribution.

CentOS 7.6 was to perform these steps. Here are links to the resources that I used:

Getting the OS ready

We will need to install the following before installing the Python related tools:

sudo yum groupinstall -y “development tools”
sudo yum -y install git zlib-devel openssl-devel

Install pyenv

pyenv is a tool used to manage Python installations. It provides functionality such as letting you have multiple Python versions on the same machine. You can install it by running:

curl | bash

At the end of the installation it instructs you to add the following to your ~/.bashrc file:

add to .bashrc
export PATH=”/home/chris/.pyenv/bin:$PATH”
eval “$(pyenv init -)”
eval “$(pyenv virtualenv-init -)”

Re-log into your shell after this is done.

Install Python 3.6

pyvmomi says the latest version that it’s compatible with is 3.6 so let’s install that. You can list all available Python distributions by running:

pyenv install –list

Install Python 3.6.0

pyenv install -v 3.6.0

Verify that 3.6.0 was installed

pyenv versions
* 3.6.0 (set by /home/chris/.python-version)

Install pipenv

pipenv is a tool used to manage Python projects and uses virtual environments in the background. We can install pipenv with pip. If you don’t have pip, you can install it by running:

curl -o
python –user

Install pipenv:

pip install pipenv –user

Install a Python 3 (3.6.0) virtual environment:

pipenv install –three

Start up a new shell using the virtual environment:

pipenv shell

Verify the Python version:

python -V
Python 3.6.0

Install pyvmomi community samples

Clone the pyvmomi Github repo:

git clone

Change into the samples directory:

cd pyvmomi-community-samples/

Install everything:

python install

Run a sample script that will return all VMs in a vCenter:

./samples/ -S -s vc65b.vmware.local -u cloudadmin -p VMware1!

There are 78 scripts in the samples directory that you can experiment with  and adapt as needed.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s