Python PIP

PIP is a package management system that installs and maintains Python software packages. Since Python version 3.4, PIP is included by default.

On Windows, you can find PIP in the following folder:


PIP looks for packages on the Python Package Index (PyPI), a repository for Python packages.

Let’s look at a package. Since we are network people, let’s check out the networkparse package. Networkparse makes it easy to work with hierarchical network configuration files. This is the project page:

Pip Networkparse Project Page

Networkparse is well maintained and has good documentation. We can install a package with the pip install command:

pip install networkparse
Collecting networkparse
  Downloading networkparse-1.8.0-py3-none-any.whl (13 kB)
Collecting dataclasses<0.7.0,>=0.6.0
  Downloading dataclasses-0.6-py3-none-any.whl (14 kB)
Installing collected packages: dataclasses, networkparse
Successfully installed dataclasses-0.6 networkparse-1.8.0

I’ll use one of the examples from their documentation. First, we import the package in our code:

from networkparse import parse

We’ll create a variable with a string which represents the running configuration of a Cisco IOS router:

running_configuration = """
hostname R1
no aaa new-model
mmi polling-interval 60
no mmi auto-configure
no mmi pvc
mmi snmp-timeout 180
ip cef
no ipv6 cef
multilink bundle-name authenticated
interface GigabitEthernet0/1
 ip address
 duplex auto
 speed auto
 media-type rj45
interface GigabitEthernet0/2
 ip address
 duplex auto
 speed auto
 media-type rj45
router bgp 1
 bgp log-neighbor-changes
 network mask
 neighbor remote-as 2
 neighbor remote-as 3
ip forward-protocol nd
no ip http server
no ip http secure-server
ipv6 ioam timestamp

line con 0
line aux 0
line vty 0 4
 transport input none
no scheduler allocate

We need to parse the configuration and assign it to the “config” variable:

>>> config = parse.ConfigIOS(running_configuration)

Now we can do some cool things. For example, show the IP addresses on all interfaces:

>>> interfaces = config.filter("interface .+")
>>> for interface in interfaces:
	ip_address = interface.children.filter("ip address .*").one()

The above code prints the following messages:

interface FastEthernet0/0
ip address
interface FastEthernet0/1
ip address
interface FastEthernet1/0
ip address

This is a simple example but now you know how you can install packages with PIP.


You have now learned how to use PIP to install packages for Python:

  • How to verify where PIP is located on your computer.
  • How to look for packages on PyPI.
  • How to install packages with PIP.
  • How to use packages in your Python code.

I hope you enjoyed this lesson. If you have any questions, please leave a comment.

Forum Replies

  1. Hi Rene
    I am having issues importing parse from networkparse. Currently getting the following error:

    "Traceback (most recent call last):
      File "", line 1, in 
      File "C:\Python39\lib\site-packages\networkparse\", line 7, in 
        from . import parse
      File "C:\Python39\lib\site-packages\networkparse\", line 23, in 
        import pyparsing
    ModuleNotFoundError: No module named 'pyparsing'"

    I have added the path to python manually into Windows 10 but sadly that has not helped.

    As an aside can I also ask you just to walk through the meaning and sy

    ... Continue reading in our forum

  2. Hello Frank,

    When you get an error like this:

    ModuleNotFoundError: No module named 'pyparsing'"

    It’s always related that Python is unable to find your module. In this case, it seems that the networkparse module is trying to import the pyparsing module. We can see it here:

    File "C:\Python39\lib\site-packages\networkparse\", line 23, in 
        import pyparsing
    ModuleNotFoundError: No module named 'pyparsing'"

    When you look at the file, you can see this on line 23:

    import pyparsing

    Try using pip to install pyparsing:

    pip install pyparsing

    That shou

    ... Continue reading in our forum

  3. Hi Rene,

    That is much better, and I now get no errors, and all commands appear to run.

    I just don’t get any print from the code in the last phase, using your configuration file and/or similar .conf .txt etc.


Ask a question or join the discussion by visiting our Community Forum