View Only

Scripting How-To: Install the Junos PyEZ library

By Erdem posted 04-12-2014 20:02


Install the PyEZ Library


Junos PyEZ has been built and tested with Python 2.6 and 2.7.


NOTE: Earlier versions of Python are known not to work. Additionally, no testing has been performed with Python 3.3 at this time.


System Requirements


Some of the project dependencies require OS system libraries. The ncclient package specifically requires libxml2 and libxslt installed on the system.
IMPORTANT: Before you begin installing Junos PyEZ, make sure that you have these libraries installed.



  • python-pip
  • python-dev
  • libxml2-dev
  • libxslt-dev
  • libssl-dev
  • libffi-dev


  • python-pip
  • python-devel
  • libxml2-devel
  • libxslt-devel
  • libffi-devel
  • gcc
  • openssl


  • py27-pip
  • libxml2
  • libxslt




Versions of Junos PyEZ are uploaded to PyPI for ease of installation.


NOTE: This process assumes "pip" is for Python 2.7.


1 # Install the Junos "EZ" library:
2 pip install junos-eznc




To get the "latest and greatest" code, you can obtain it directly from github.


NOTE: This process assumes "python" is version 2.7 and the git system package has been installed.

3 or






11-25-2015 09:58


Sorry, didn't realize this was out here.  You probably have this fixed but here is an answer for anyone that sees this error:

AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'


It is most likely (not always) a case of using python-openssl and it doesn't have a parameter for set_tlsext_host_name


Easiest way to fix it is this:


apt-get purge python-openssl
apt-get install libffi-dev python-pip
pip2.7 install -U pyopenssl==0.13.1

Assuming you are using Ubuntu.  Use yum/dnf for Fedora/CentOS or whatever package manger you have for your distribution.


09-08-2015 14:39

Hey everyone,


I am a newbie in automation . I was trying to create a virtual environment on one of our linux boxes and then install jnpr-eznc there. While doing the same i am getting the following error messages and would appreciate if someone can help.


Error message:


(my_project)raghav@sjd-ra1-8b:~/my_project$ pip install junos-eznc
Collecting junos-eznc
Traceback (most recent call last):
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/", line 211, in main
    status =, args)
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/commands/", line 294, in run
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/req/", line 334, in prepare_files
    functools.partial(self._prepare_file, finder))
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/req/", line 321, in _walk_req_to_install
    more_reqs = handler(req_to_install)
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/req/", line 461, in _prepare_file
    req_to_install.populate_link(finder, self.upgrade)
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/req/", line 250, in populate_link = finder.find_requirement(self, upgrade)
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/", line 486, in find_requirement
    all_versions = self._find_all_versions(
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/", line 404, in _find_all_versions
    index_locations = self._get_index_urls_locations(project_name)
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/", line 378, in _get_index_urls_locations
    page = self._get_page(main_index_url)
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/", line 818, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/", line 928, in get_page
    "Cache-Control": "max-age=600",
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/_vendor/requests/", line 477, in get
    return self.request('GET', url, **kwargs)
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/", line 373, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/_vendor/requests/", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/_vendor/requests/", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/_vendor/cachecontrol/", line 46, in send
    resp = super(CacheControlAdapter, self).send(request, **kw)
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/_vendor/requests/", line 370, in send
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/", line 544, in urlopen
    body=body, headers=headers)
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/", line 341, in _make_request
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/", line 761, in _validate_conn
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/", line 238, in connect
  File "/home/raghav/my_project/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/contrib/", line 279, in ssl_wrap_socket
AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'



11-19-2014 20:15

nitinkr says:
@sdwang, you are right

I checked with another M10 device (with latest build) it has got serial number and hence same code is working for me, older version seems to have missing serial number and leading to exception in PyEZ code. You can raise a request on github, We will try to fix the same.
Item Version Part number Serial number Description
Chassis K1XXX M10I
Midplane REV 09 710-00YYYY AADBYYYY M10i Midplane
Posted 09:38, 19 Nov 2014

11-17-2014 20:14

sdwang says:
Hit the following error while wanting to connect the device.
any idea?


>>> dev =Device(host=host,user=user,password=pwd)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python27\lib\site-packages\junos_eznc-1.0.2-py2.7.egg\jnpr\junos\devi", line 439, in open
File "c:\Python27\lib\site-packages\junos_eznc-1.0.2-py2.7.egg\jnpr\junos\devi", line 660, in facts_refresh
gather(self, self._facts)
File "c:\Python27\lib\site-packages\junos_eznc-1.0.2-py2.7.egg\jnpr\junos\fact
s\", line 52, in facts_chassis
IndexError: list index out of range
Posted 20:12, 17 Nov 2014

11-17-2014 20:14

sdwang says:
For some old device like M10, the serial number of chassis/midplane might be empty. So I think this is a robust issue of this module.
Hardware inventory:
Item Version Part number Serial number Description
Routing Engine REV 07 740-007603 P11075101453 RE-3.0
Posted 21:46, 17 Nov 2014

09-24-2014 20:13

simonmao says:
If no pip file under /Library/Python/2.7/site-packages , need install pip first.
$ sudo easy_install pip ;
$ sudo pip install pip --upgrade
$ sudo /usr/local/bin/pip install junos-eznc
$ pip install git+

-Simon Mao
Posted 07:26, 24 Sep 2014

09-17-2014 20:13

tjordan says:
I tried to install Python and PyEZ on a 64bit Windows environment. I was unable to find 64 bit versions for some of the modules, the install consequently failed when I tried to load any Juniper libraries. However, when I started over with a fresh Python install using all 32-bit versions and it worked.
Posted 07:23, 17 Sep 2014

06-18-2014 20:13

jschulman says:
@Gary - excellent, thank you for sharing the fix with the community!
Posted 12:38, 18 Jun 2014

06-18-2014 20:12

ggreenberg says:
I just found the fix for this... you need to run the following command to install Xcode command line tools before running the junos-eznc install...

xcode-select --install
Posted 12:25, 18 Jun 2014

06-18-2014 20:12

jschulman says:
@Gary - yes, it means you do not have the libxml2 devel package installed; or not in the right environment variables. Please see the "System Requirements" section in the above documentation. If that fails, please do post your questions on the Google Group for PyEZ here:!forum/junos-python-ez - we're starting to get a nice community of folks helping each other.

-- Jeremy
Posted 12:16, 18 Jun 2014

06-18-2014 20:11

ggreenberg says:
I am getting the following error when running "sudo -E pip install junos-eznc"...

Any ideas?


In file included from src/lxml/lxml.etree.c:346:

/private/var/folders/l0/5s5y9wlj7_5f824n8tf2_fw0000_6l/T/pip_build_root/lxml/src/lxml/includes/etree_defs.h:9:10: fatal error: 'libxml/xmlversion.h' file not found

#include "libxml/xmlversion.h"


1 error generated.

error: command 'cc' failed with exit status 1
Posted 12:02, 18 Jun 2014

05-07-2014 20:10

dspry says:
For Joao and others who may be having an issue getting this to install try the following:

$ sudo pip install pip --upgrade
$ sudo /usr/local/bin/pip install junos-eznc

This worked for a few Ubuntu machines that had the same issue.Edited 11:37, 7 May 2014
Posted 11:35, 7 May 2014

04-15-2014 20:10 says:
An FYI to those running OSX Mavericks 10.9.2 and the built in version of Python. To install successfully, I had to run this:

sudo -E pip install junos-eznc

Also ensure that you've downloaded the xcode command line tools from the Apple developer site. They're not on the app store server, so they won't be automagically fetched for you when you try to run: xcode-select --install
Posted 00:40, 15 Apr 2014