Friday, November 27, 2015

Installing Juniper's PyEZ on Mac OS X (Part 1)

My goal is to install Juniper's PyEZ on my Macbook Air so that I can do some work while hanging out with friends. As many of my friends do, we hang out having coffee for awhile and then the topic of discussion usually turns into technical. From than on, if enough people curious, it turns into a mini-hackaton. LOL. I think we spend too much time on this and not enough on non-technical thing. Getting a life is probably is a good thing too *giggle*

As a tools, my 11" MBA is hard to beat. The keyboard is full size - except for the tiny arrow keys on the right. The screen is more than adequate. The battery life is awesome. And it is light. Not as light as the new Macbook, but it is light enough. An at less than $999, it is hard to beat.

Anyway, my note for today is how to install "Juniper's PyEZ" on my Macbook Air. Let spend some time on the PyEZ. This post contains the first part of my installation which covers getting most of the Python library in place. The next blog will continue with the installation.

Juniper's PyEZ

PyEZ is a Python power-shell that you can use to interact with Juniper's routers. It is based on Netconf (see RFC6241) Supposedly it provides a consistent interface to a router such that you can - at least in theory - using a unify program/interface to talk to elements in your multi-vendor network. (commentary... you can see how well it works such that there is another movement to unify further via openconfig.org)

I checked out Juniper's web site and it listed the requirement of installing:

  • Xcode
  • pip
This is simple enough since I always have "Xcode" installed, this gonna be a piece of cake. For "pip", you can see my other blog.

The next step is to install "PyEZ" using "pip install junos-pyez". Unfortunately, this won't work cuz I got an error while compiling it. Here's my error on the screen: (Note the cute ASCII scroll bar, it's so '80s LOL.)

reia-mba:/usr/bin reia$ sudo pip install junos-eznc
Password:
The directory '/Users/reia/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/reia/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting junos-eznc
  Downloading junos-eznc-1.2.3.tar.gz (62kB)
    100% |████████████████████████████████| 65kB 98kB/s 
Collecting lxml>=3.2.4 (from junos-eznc)
  Downloading lxml-3.5.0.tar.gz (3.8MB)
    100% |████████████████████████████████| 3.8MB 73kB/s 
Collecting ncclient>=0.4.3 (from junos-eznc)
  Downloading ncclient-0.4.6.tar.gz (57kB)
    100% |████████████████████████████████| 61kB 83kB/s 
Collecting paramiko>=1.15.2 (from junos-eznc)
  Downloading paramiko-1.16.0-py2.py3-none-any.whl (169kB)
    100% |████████████████████████████████| 172kB 163kB/s 
Collecting scp>=0.7.0 (from junos-eznc)
  Downloading scp-0.10.2-py2.py3-none-any.whl
Collecting jinja2>=2.7.1 (from junos-eznc)
  Downloading Jinja2-2.8-py2.py3-none-any.whl (263kB)
    100% |████████████████████████████████| 266kB 113kB/s 
Collecting PyYAML>=3.10 (from junos-eznc)
  Downloading PyYAML-3.11.tar.gz (248kB)
    100% |████████████████████████████████| 249kB 115kB/s 
Collecting netaddr (from junos-eznc)
  Downloading netaddr-0.7.18-py2.py3-none-any.whl (1.5MB)
    100% |████████████████████████████████| 1.5MB 120kB/s 
Requirement already satisfied (use --upgrade to upgrade): setuptools>0.6 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from ncclient>=0.4.3->junos-eznc)
Collecting ecdsa>=0.11 (from paramiko>=1.15.2->junos-eznc)
  Downloading ecdsa-0.13-py2.py3-none-any.whl (86kB)
    100% |████████████████████████████████| 90kB 195kB/s 
Collecting pycrypto!=2.4,>=2.1 (from paramiko>=1.15.2->junos-eznc)
  Downloading pycrypto-2.6.1.tar.gz (446kB)
    100% |████████████████████████████████| 446kB 77kB/s 
Collecting MarkupSafe (from jinja2>=2.7.1->junos-eznc)
  Downloading MarkupSafe-0.23.tar.gz
Installing collected packages: lxml, ecdsa, pycrypto, paramiko, ncclient, scp, MarkupSafe, jinja2, PyYAML, netaddr, junos-eznc
  Running setup.py install for lxml
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-3YToOU/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-QXJfAy-record/install-record.txt --single-version-externally-managed --compile:
    Building lxml version 3.5.0.
    Building without Cython.
    Using build configuration of libxslt 1.1.28
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.11-intel-2.7
    creating build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/__init__.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/_elementpath.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/builder.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/cssselect.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/doctestcompare.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/ElementInclude.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/pyclasslookup.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/sax.py -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/usedoctest.py -> build/lib.macosx-10.11-intel-2.7/lxml
    creating build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/__init__.py -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    creating build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/__init__.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/_diffcommand.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/_html5builder.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/_setmixin.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/builder.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/clean.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/defs.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/diff.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/ElementSoup.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/formfill.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/html5parser.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/soupparser.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    copying src/lxml/html/usedoctest.py -> build/lib.macosx-10.11-intel-2.7/lxml/html
    creating build/lib.macosx-10.11-intel-2.7/lxml/isoschematron
    copying src/lxml/isoschematron/__init__.py -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron
    copying src/lxml/lxml.etree.h -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/lxml.etree_api.h -> build/lib.macosx-10.11-intel-2.7/lxml
    copying src/lxml/includes/c14n.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/config.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/dtdvalid.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/etreepublic.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/htmlparser.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/relaxng.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/schematron.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/tree.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/uri.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/xinclude.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/xmlerror.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/xmlparser.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/xmlschema.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/xpath.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/xslt.pxd -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/etree_defs.h -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    copying src/lxml/includes/lxml-version.h -> build/lib.macosx-10.11-intel-2.7/lxml/includes
    creating build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources
    creating build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/rng
    copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/rng
    creating build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl
    creating build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.macosx-10.11-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    running build_ext
    building 'lxml.etree' extension
    creating build/temp.macosx-10.11-intel-2.7
    creating build/temp.macosx-10.11-intel-2.7/src
    creating build/temp.macosx-10.11-intel-2.7/src/lxml
    cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/usr/include/libxml2 -Isrc/lxml/includes -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.11-intel-2.7/src/lxml/lxml.etree.o -w -flat_namespace
    In file included from src/lxml/lxml.etree.c:323:
    src/lxml/includes/etree_defs.h:14:10: fatal error: 'libxml/xmlversion.h' file not found
    #include "libxml/xmlversion.h"
             ^
    1 error generated.
    Compile failed: command 'cc' failed with exit status 1
    creating tmp
    cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitzzAQot.c -o tmp/xmlXPathInitzzAQot.o
    /tmp/xmlXPathInitzzAQot.c:1:10: fatal error: 'libxml/xpath.h' file not found
    #include "libxml/xpath.h"
             ^
    1 error generated.
    *********************************************************************************
    Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
    Perhaps try: xcode-select --install
    *********************************************************************************
    error: command 'cc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-3YToOU/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-QXJfAy-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-3YToOU/lxml
reia-mba:/usr/bin reia$

Unfortunately, after all these works, it is not enough. The problem is that "easy_install" can't file libxml version number. Ok, it is a good practice to make sure you have the right thing install, but wow, how come it doesn't work?

A little more googling and I found out that there is actually a better instruction on how to install the PyEZ. I found it on Juniper's github page -

https://github.com/Juniper/py-junos-eznc/blob/master/INSTALL-OSX.md
I probably can be shameless and copy the content here. However, I don't feel like doing this today. LOL. So may be when I don't have anything better to do I'll do that.
Anyway, you follow the instruction on that page and you should be able to install your PyEZ. I haven't finished the installation, yet. So I'm sure I will post more stuffs in a couple of days.

Later Loves.

ReiA

No comments:

Post a Comment