Python PIP

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\parse.py", line 23, in 
    import pyparsing
ModuleNotFoundError: No module named 'pyparsing'"

When you look at the parse.py 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 parse.py 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:

Rene