# Python PIP

**URL:** https://forum.networklessons.com/t/python-pip/10624
**Category:** Lessons Discussion
**Created:** [April 8, 2020, 10:15am UTC](https://forum.networklessons.com/t/python-pip/10624 "2020-04-08T10:15:23Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [April 8, 2020, 10:15am UTC](https://forum.networklessons.com/t/python-pip/10624/1 "2020-04-08T10:15:23Z")

</div>

This topic is to discuss the following lesson:

> **[Python PIP](https://networklessons.com/python/python-pip)**
>
> This lesson explains how to use PIP to install Python Packages from the PyPI package repository. We also explain how to use a Python package in your code.

---

<div class="post-metadata">

### Author: ![faithfps](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/f/bb73d2/32.png) [@faithfps](https://forum.networklessons.com/u/faithfps)
#### Post date: [March 4, 2021, 4:05pm UTC](https://forum.networklessons.com/t/python-pip/10624/2 "2021-03-04T16:05:42Z")

</div>

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\ __init__.py", line 7, in 
    from . import parse
  File "C:\Python39\lib\site-packages\networkparse\parse.py", 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,  
Frank

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [March 8, 2021, 1:17pm UTC](https://forum.networklessons.com/t/python-pip/10624/3 "2021-03-08T13:17:59Z")

</div>

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:

[https://gitlab.com/xylok/networkparse/-/blob/master/networkparse/parse.py](https://gitlab.com/xylok/networkparse/-/blob/master/networkparse/parse.py)

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

[networkparse\_parse.txt](https://forum.networklessons.com/uploads/short-url/ck6qq3MnkaeQtkIG4cWA8zyY3ZO.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? 🙂

Rene

---

<div class="post-metadata">

### Author: ![faithfps](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/f/bb73d2/32.png) [@faithfps](https://forum.networklessons.com/u/faithfps)
#### Post date: [March 17, 2021, 5:21pm UTC](https://forum.networklessons.com/t/python-pip/10624/4 "2021-03-17T17:21:53Z")

</div>

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.

Thanks,  
Frank

---

<div class="post-metadata">

### Author: ![sushil.bhattacharje3](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@sushil.bhattacharje3](https://forum.networklessons.com/u/sushil.bhattacharje3)
#### Post date: [March 24, 2024, 2:58pm UTC](https://forum.networklessons.com/t/python-pip/10624/5 "2024-03-24T14:58:04Z")

</div>

It doesn’t work for me either. Any response would be appreciated.

> > > from networkparse import parse  
> > > import ciscoconfparse  
> > > from networkparse import parse  
> > > config = parse.ConfigIOS(running\_configuration)  
> > > Traceback (most recent call last):  
> > > File “”, line 1, in   
> > > NameError: name ‘running\_configuration’ is not defined  
> > > dir(ciscoconfparse)  
> > > [‘ACTIVE\_LOGURU\_HANDLERS’, ‘ALL\_ASA\_FACTORY\_CLASSES’, ‘ALL\_BRACE\_SYNTAX’, ‘ALL\_IOSXR\_FACTORY\_CLASSES’, ‘ALL\_IOS\_FACTORY\_CLASSES’, ‘ALL\_JUNOS\_FACTORY\_CLASSES’, ‘ALL\_NXOS\_FACTORY\_CLASSES’, ‘ALL\_VALID\_SYNTAX’, ‘ASAAclLine’, ‘ASACfgLine’, ‘ASAHostnameLine’, ‘ASAIntfGlobal’, ‘ASAIntfLine’, ‘ASAName’, ‘ASAObjGroupNetwork’, ‘ASAObjGroupService’, ‘ASAObjNetwork’, ‘ASAObjService’, ‘BaseCfgLine’, ‘CFGLINE’, ‘CiscoConfParse’, ‘CiscoIOSInterface’, ‘CiscoIOSXRInterface’, ‘CiscoPassword’, ‘CiscoRange’, ‘ConfigList’, ‘DNSException’, ‘DNSResponse’, ‘Diff’, ‘DiffObject’, ‘ENCODING’, ‘HDiff’, ‘IOSAaaCommandsAccountingLine’, ‘IOSAaaCommandsAuthorizationLine’, ‘IOSAaaConsoleAuthorizationLine’, ‘IOSAaaEnableAuthenticationLine’, ‘IOSAaaExecAccountingLine’, ‘IOSAaaGroupServerLine’, ‘IOSAaaLoginAuthenticationLine’, ‘IOSAccessLine’, ‘IOSCfgLine’, ‘IOSHostnameLine’, ‘IOSIntfGlobal’, ‘IOSIntfLine’, ‘IOSRouteLine’, ‘IOSXRCfgLine’, ‘IOSXRIntfLine’, ‘IPv4Obj’, ‘IPv6Obj’, ‘InvalidParameters’, ‘JunosCfgLine’, ‘L4Object’, ‘MutableSequence’, ‘NXOSAaaCommandsAccountingLine’, ‘NXOSAaaCommandsAuthorizationLine’, ‘NXOSAaaConsoleAuthorizationLine’, ‘NXOSAaaEnableAuthenticationLine’, ‘NXOSAaaExecAccountingLine’, ‘NXOSAaaGroupServerLine’, ‘NXOSAaaLoginAuthenticationLine’, ‘NXOSAccessLine’, ‘NXOSCfgLine’, ‘NXOSHostnameLine’, ‘NXOSIntfGlobal’, ‘NXOSIntfLine’, ‘NXOSRouteLine’, ‘NXOSvPCLine’, ‘PythonOptimizeCheck’, ‘RequirementFailure’, ‘Resolver’, ‘Sequence’, ‘\_’, ‘ **builtins** ’, ‘ **cached** ’, ‘ **ccp\_re** ’, ‘ **doc** ’, ‘ **file** ’, ‘ **loader** ’, ‘ **name** ’, ‘ **package** ’, ‘ **path** ’, ‘ **spec** ’, ‘\_get\_ipv4’, ‘\_get\_ipv6’, ‘as\_text\_list’, ‘assign\_parent\_to\_closing\_braces’, ‘build\_space\_tolerant\_regex’, ‘ccp\_abc’, ‘ccp\_logger\_control’, ‘ccp\_util’, ‘cfgobj\_from\_text’, ‘check\_valid\_ipaddress’, ‘ciscoconfparse’, ‘collapse\_addresses’, ‘config\_line\_factory’, ‘configure\_loguru’, ‘convert\_junos\_to\_ios’, ‘copy’, ‘datetime’, ‘deprecated’, ‘dns6\_lookup’, ‘dns\_lookup’, ‘dns\_query’, ‘enforce\_valid\_types’, ‘errors’, ‘fix\_repeated\_words’, ‘get\_version\_number’, ‘hier\_config’, ‘initialize\_ciscoconfparse’, ‘initialize\_globals’, ‘inspect’, ‘ip\_factory’, ‘is\_not’, ‘junos\_unsupported’, ‘locale’, ‘log\_function\_call’, ‘logger’, ‘models\_asa’, ‘models\_cisco’, ‘models\_iosxr’, ‘models\_junos’, ‘models\_nxos’, ‘os’, ‘parse\_global\_options’, ‘parse\_line\_braces’, ‘partial’, ‘pathlib’, ‘protocol\_values’, ‘re’, ‘reverse\_dns\_lookup’, ‘run\_this\_posix\_command’, ‘sys’, ‘time’, ‘toml’, ‘warnings’, ‘yaml’]  
> > > dir(parse)  
> > > [‘ConfigASA’, ‘ConfigBase’, ‘ConfigFortigate’, ‘ConfigHPCommware’, ‘ConfigIOS’, ‘ConfigJunos’, ‘ConfigLine’, ‘ConfigLineList’, ‘ConfigNXOS’, ‘List’, ‘MultipleLinesError’, ‘NoLinesError’, ‘OneIndexedList’, ‘Optional’, ‘UnknownConfigError’, ‘VersionNumber’, ‘ **builtins** ’, ‘ **cached** ’, ‘ **doc** ’, ‘ **file** ’, ‘ **loader** ’, ‘ **name** ’, ‘ **package** ’, ‘ **spec** ’, ‘automatic’, ‘dataclass’, ‘line\_parse\_checker’, ‘math’, ‘namedtuple’, ‘pyparsing’, ‘re’]

---

<div class="post-metadata">

### Author: ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)
#### Post date: [March 27, 2024, 7:10am UTC](https://forum.networklessons.com/t/python-pip/10624/6 "2024-03-27T07:10:32Z")

</div>

Hello Sushil

Your particular case seems to be different than that described by @faithfps in his [post here](https://forum.networklessons.com/t/python-pip/10624/2). In the output you shared, there is a NameError that states that the running\_config variable is not defined. Make sure that, as in the lesson, you have parsed the configuration and assigned it to this config variable. Take a look at this particular configuration and let us know if you were able to resolve it.

I hope this has been helpful!

Laz
