Installing Python in Windows

There are some specific things you will want to do to install Python on Windows as it will act differently than it would on a linux machine. Some of the steps are specific to running scripts for Nexus (NX-OS). This article was written by Jeff Allen at Cisco.

Step-by-step guide

  1.  Install Python 2.x (do not install 3.x) from here . I chose Python 2.7 and I chose 32bit because I assume it is more compatible with other stuff but I have basis to back that up. 
  2. You will then need Python for Windows Extensions installed from here.
    Click the latest build and download the one matched to your version of python and 32bit/64bit
    Install it – if it complains that Python was not found in your registry, add the python path (c:\python27) to this key:
    HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.7\InstallPath
    Change the (default) string value on the right to be your python path (c:\python27)
  3. In order to run the “install” scripts for Python packages like WinPexpect (step 4), you need something called “setuptools”. Download it here.
    Download the ez_setup.py file here.
    Go to a command prompt and run ‘ez_setup.py’ from the downloads folder
  4. You need Pexpect in order to run a lot of Nexus scripts and Pexpect for Windows is called WinPexpect. Download it from here.
    Save it to a folder inside the python path (c:\python27\pexpect)

    From a command prompt run:

  5. Download and install the correct version (for your Python) of the lxml parser which the NXOS modules use here
Nexus 9K scripts
Now you should be able to run sample Nexus 9K python scripts. But to get them, you need to do this:
  1. Download the 9K tgz from here.
  2. Install 7zip to unzip it. There are some folders inside that you need to move to the correct place. You will need to make sure that in the end you have:
  • C:\python27\remote_client\cisco\…
  • C:\python27\remote_client\utils\…
  • C:\python27\client_example.py

Questions? Contact jeff@cisco.com or hit the alias net-prog@googlegroups.com. Please mind these examples are for Python 2.7 and your experience may be different on another version (only 2.7 is supported with Nexus as of writing)