Python PIP

This topic is to discuss the following lesson:

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 syntax of the
config = parse.ConfigIOS(running_configuration) section.

Many Thanks,

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 should solve your issue.

Let me explain this line:

config = parse.ConfigIOS(running_configuration)

In our code, we used from networkparse import parse to import the parse module from the “networkparse” module.

If you want to see what looks like, we can check the git repository here:

I added this file to this post in case it changes in the future and someone wants to follow along.

networkparse_parse.txt (22.3 KB)

The parse module contains a class named ConfigIOS that we call. Our variable running_configuration is the argument that we send to the ConfigIOS class.

I haven’t explained classes in the course, it’s difficult to explain in one or two sentences. Python is an object-oriented programming language. In a nutshell, a class is a blueprint/template for an object. If you look at the code in the repository, you can see the ConfigIOS class is used to parse the configuration file for Cisco IOS.

Does this help? :slight_smile:


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.