Search
  • Paul Kennard

Brain Byte - Python and PIP on Windows 10

Welcome all ITBODs, to this ITBOD Brain Byte post where I will cover the basics around installing Python and the Python Package Installer on Windows 10 to get you up and ready with the initial focus towards VMware Automation with Python.


What is Python

Python it’s a high level, cross-platform multipurpose programming language & was first released in 1991.


Python has continued to evolve as a versatile tool over the years & has a large community for support and development, allowing you to deal with complex systems and data with minimal lines of code and saving you time.


What is PIP

The Python Package Installer or PIP as its most commonly known. If you already have Python installed you likely already have PIP.


PIP allows you to install packages from the Python Package Index (PyPi) , I am going to start with pyVmomi which is the Python SDK for VMware vSphere API and will allow me to manage both vCenter & ESXi hosts.


There’s so many PyPi packages in the repository that cover a plethora of areas so I also encourage you to search for projects at https://pypi.org/.


Installing Python on Windows 10


Method 1 - Microsoft Store


1. To check if Python is installed open a Windows command prompt and type and run:

python

2. The Microsoft Store should pop open and direct you to the the latest stable release. Click Get and wait for the install complete.

3. After installing now when you open command prompt and run the same python command this time it will work and open the Python primary prompt (>>>) shown:


Note: Other versions were available within the MS Store for download

  • Python 3.7 - For “Evaluation purposes

  • Python 3.9 - At the time listed for “public testing

4. From command prompt type the following to show the version of pip included:

pip --version

Method 2 - Direct Download


The direct download of Python is just as easy to install and also offers some additional opportunity's towards customizing your install.


1. Open your browser to the download page:

https://www.python.org/downloads/windows/

2. Download and run installer


3. Checking the “Add Python 3.9 to PATH” adds a windows environment variable allowing you to access python at command prompt rather than specify the full path to the program, I chose Customize installation to show options in this case.


4. Optional Features as part of customized install. Click Next to continue.


5. Advanced Options available, click Install to continue.


IDLE Python

By default with Python you also get the IDLE Python application, which is the Integrated Learning and Development Environment and is an excellent place to practice and develop your skills.

Upgrading PIP


Upgrade PIP to the latest version, run the following command:

python.exe -m pip install --upgrade pip

Adding first Package


1. To see what packages come included, you can run the following from command:

python -m pip list

2. Install the VMware vSphere Python SDK run the following command:

pip install --upgrade pyvmomi

3. Running command to list packages again you will now see the one requested, plus other packages as part of the install:

certifi = Collection of Root Certificates to validating SSL certs chardet = Python Universal Character Encoding Detector idna = Provides support for IDNA Internationalised Domain Names in Applications pyvmomi = Python SDK for the VMware vSphere API requests = Python HTTP library six = Allows for Python 2/3 compatibility urllib3 = HTTP client for Python This concludes this post and if you have followed end to end should be ready to play with Python and the SDK to to manage your VMware environments.


In my next post, I will cover some VMware tasks that can be run with the Python SDK for VMware vSphere and see if we can’t set it to work to help the IT BODs out there.

Thanks and all the best

ITBOD365-576x528.gif

Cloud & Virtualization Blog by ITBOD - paul kennard

linkedin.png
twitter.png
facebook.png
rss.png
Home.png
Arrow.png