Automation

 View Only
last person joined: 6 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  PyEZ and VSCode - Could not resolved Pylance (ReportMissingImports)

    Posted 03-17-2022 05:32
    Edited by Michael Pappas 03-17-2022 09:59
    Hi Everyone,

    First let me admit that I am new in Python Programming and network automation. I am working with Junos PyEZ Table and Views and when I try to import a predefined Table from junos PyEZ jnpr.junos.op module, the VSCode shows a warngin message as;

    Import "jnpr.junos.op.arp" could not be resolvedPylancereportMissingImports

    What this warning means? And how I can solve this issue?

    Many Regards
    Arslan


  • 2.  RE: PyEZ and VSCode - Could not resolved Pylance (ReportMissingImports)

     
    Posted 03-21-2022 16:43
    Hi,

    I'm not sure what the code is that you are executing to load the predefined table to Arp is.

    But the following will load them.

    from jnpr.junos import Device
    from jnpr.junos.op.arp import ArpTable​

    If that fails to run correctly for you, then please share some additional information. e.g.
    # pip3 list
    # python3 --version​

    Regards.

    ------------------------------
    Andy Sharp
    ------------------------------



  • 3.  RE: PyEZ and VSCode - Could not resolved Pylance (ReportMissingImports)

     
    Posted 03-22-2022 09:48
    Hello Arslan,

    VScode works great with Python, but you'll need to tell it where to look for Python if you're using anything other than default path.

    Example, if you follow best practices then you likely created a Python virtual environment and installed PyEZ within it. You will need to tell VScode to look for your Python goodies in this environment instead of the default location, or it will complain that it cannot find any of your packages.

    You can do this by holding Control + Shift and pressing the letter P within VScode, this opens up a shortcut menu where you can change the path by searching for "python path", and finally pointing to your virtual environment's Python binary.

    This will help VScode find your Python libraries and stop reporting these issues through Pylance

    ------------------------------
    Calvin Remsburg | Global Enterprise Architect | Juniper Networks
    ------------------------------