Import Error: jnpr.junos - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: News and Discussions (https://python-forum.io/forum-31.html) +--- Thread: Import Error: jnpr.junos (/thread-24585.html) |
Import Error: jnpr.junos - otay - Feb-20-2020 I am very new at the python. I am using window 10 version python 3.7.4. I am trying to connect Juniper switch using pyhon script. I am trying use the library called jnpr.junos. What I am confuse about is how python works when I excute from command line "jnpr.junos import Device" how dows it know where to get this lib files from? I would like to work in standalone mode so no internet is connected it will be in private network. is this posiable? How do I down load the library and install in which directory? see below for the error. Any help I would greatly appricated. --------------------------- Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from jnpr.junos import Device File "<stdin>", line 1 from jnpr.junos import Device ^ IndentationError: unexpected indent >>> >>> ModuleNotFoundError: No module named 'jnpr' ----------------------------- - Otay RE: Import Error: jnpr.junos - snippsat - Feb-20-2020 (Feb-20-2020, 06:51 PM)otay Wrote: I would like to work in standalone mode so no internet is connected it will be in private network. is this posiable? How do I down load the library and install in which directory? see below for the error.You install with pip install junos-eznc ,all is done automatically download and install.It dos install many libraries,here a run with virtual environment. You can drop virtual environment not required and just install. C:\code λ python -m venv junos_env C:\code λ cd junos_env\ C:\code\junos_env λ C:\code\junos_env\Scripts\activate (junos_env) C:\code\junos_env λ pip install junos-eznc Collecting junos-eznc Downloading ..... Successfully installed MarkupSafe-1.1.1 ..... # Test that it work. (junos_env) C:\code\junos_env λ python Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from jnpr.junos import Device >>> from jnpr.junos.exception import ConnectError >>> >>> exit() # Libraries it install (junos_env) C:\code\junos_env λ pip list Package Version --------------------- ------- bcrypt 3.1.7 cffi 1.14.0 cryptography 2.8 Jinja2 2.11.1 junos-eznc 2.3.1 lxml 4.5.0 MarkupSafe 1.1.1 ncclient 0.6.7 netaddr 0.7.19 paramiko 2.7.1 pip 18.1 pycparser 2.19 PyNaCl 1.3.0 pyparsing 2.4.6 pyserial 3.4 PyYAML 5.3 scp 0.13.2 setuptools 40.6.2 six 1.14.0 transitions 0.7.2 yamlordereddictloader 0.4.0So as you see it works. You have one white-space to much. And probably not install correct as ModuleNotFoundError.
RE: Import Error: jnpr.junos - otay - Feb-21-2020 Thanks Snipset! unfortunaly I was not successfull with "pip install junos-eznc". It seems that Failed to establish due to could not find a version. Any thoughts? -Otay ------------------------------------------------------------ C:\Users\Otay\AppData\Local\Programs\Python\Python37\Scripts>pip install junos-eznc Collecting junos-eznc WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x0000022033E04348>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/junos-eznc/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x0000022033E04E08>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/junos-eznc/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x0000022033E09088>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/junos-eznc/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x0000022033E09508>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/junos-eznc/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x0000022033E09A08>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/junos-eznc/ ERROR: Could not find a version that satisfies the requirement junos-eznc (from versions: none) ERROR: No matching distribution found for junos-eznc ------------------------------- RE: Import Error: jnpr.junos - snippsat - Feb-21-2020 Look like problem with your network. If you ping PyPi ping pypi.python.org dos that work.Other tips try run cmd as admin Turn of antivirus/firewall. Run a proxy,here just a free proxy that work for me. These can go down fast,so may try several. pip install --proxy="http://1.10.141.220:34413" junos-eznc python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org junos-eznc RE: Import Error: jnpr.junos - otay - Feb-24-2020 Unfortunately, I cannot “ping pypi.python.org” since firewall is blocking and I do not have access to FW. I need to find alternate solution so I can download and put in proper directory. Thanks for your suggestion. RE: Import Error: jnpr.junos - snippsat - Feb-24-2020 If try the proxy way as shown,it may bypass the firewall. If can use git,if not just download Repo as .zip. git clone https://github.com/Juniper/py-junos-eznc.gitNow in folder py-junos-eznc do python setup.py install .(forum_env) E:\div_code\forum_env\py-junos-eznc (master) λ python setup.py install running install running bdist_egg running egg_info creating lib\junos_eznc.egg-info writing lib\junos_eznc.egg-info\PKG-INFO ......Now doing it the old way locally with no network download as pip does automatically. Other way,make it on a other Pc with Miniconda,just install normal with pip to miniconda. This miniconda folder is stand alone,so just copy folder over to Pc you want to use it. RE: Import Error: jnpr.junos - otay - Feb-24-2020 I was able to loaded with some error and now I run in to differen issue. see below. ------ C:\Users\otay\AppData\Local\Programs\Python\Python37\Scripts\py-junos-eznc-master>py setup.py install running install running bdist_egg .. .. ==> Note: I had some error see below. It might be ok since I am not connected to internet <== ;; ; Reading https://pypi.org/simple/transitions/ Download error on https://pypi.org/simple/transitions/: [Errno 11001] getaddrinfo failed -- Some packages may not be found! Couldn't find index page for 'transitions' (maybe misspelled?) Scanning index of all packages (this may take a while) Reading https://pypi.org/simple/ Download error on https://pypi.org/simple/: [Errno 11001] getaddrinfo failed -- Some packages may not be found! No local packages or working download links found for transitions error: Could not find suitable distribution for Requirement.parse('transitions') C:\Users\otay\AppData\Local\Programs\Python\Python37\Scripts\py-junos-eznc-master>running install 'running' is not recognized as an internal or external command, operable program or batch file. C:\Users\otay\AppData\Local\Programs\Python\Python37\Scripts\py-junos-eznc-master>running bdis_egg 'running' is not recognized as an internal or external command, operable program or batch file. ==> Now looking for to import module six and it not there. I do see statement in device.py import six <== C:\Users\otay\AppData\Local\Programs\Python\Python37\Scripts\py-junos-eznc-master>py Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from jnpr.junos import device Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\otay\AppData\Local\Programs\Python\Python37\lib\site-packages\junos_eznc-2.3.2.dev0-py3.7.egg\jnpr\junos\__init__.py", line 1, in <module> from jnpr.junos.device import Device File "C:\Users\otay\AppData\Local\Programs\Python\Python37\lib\site-packages\junos_eznc-2.3.2.dev0-py3.7.egg\jnpr\junos\device.py", line 3, in <module> import six ModuleNotFoundError: No module named 'six' >>> RE: Import Error: jnpr.junos - snippsat - Feb-24-2020 The problem is that in need a lot 3-party libraries that not in the Repo. So if i turn of my network and try python setup.py install it fail for my to.So then in the miniconda way the easiest,can also try the proxy way it's a common way to get past firewall. RE: Import Error: jnpr.junos - otay - Feb-26-2020 Thanks for your help! I was able to use spare laptop with no firewall in path and this work just like charm. I using pip install command with no issue. Thanks again - Otay. |