mpenning / ciscoconfparse

Parse, Audit, Query, Build, and Modify Cisco IOS-style configurations.

Home Page:http://www.pennington.net/py/ciscoconfparse/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ciscoconfparse.py doesn't import under Python3.7.0

sagarp123 opened this issue · comments

bug

Getting error invalid syntax for this line while executing the code.

Getting error invalid syntax for this line while executing the code.

  • What platform? (Windows 10, Linux, Solaris, etc...)
  • What version of python?
  • What version of ciscoconfparse?
  • How did you install ciscoconfparse?
  • What is the exact thing you're doing when you get this error?
  • Please update this github issue with the error traceback

What platform? (Windows 10, Linux, Solaris, etc...) Windows 10
What version of python? 3.7.0
What version of ciscoconfparse? 1.3.20
How did you install ciscoconfparse? pip
What is the exact thing you're doing when you get this error? parsing a config file to print all trunk ports
Please update this github issue with the error traceback

Traceback (most recent call last):
File "C:/Users/sagarpa/PycharmProjects/Project1/netmiko1.py", line 4, in
from ciscoconfparse import CiscoConfParse
File "C:\Users\sagarpa\PycharmProjects\Project1\venv\lib\site-packages\ciscoconfparse_init_.py", line 1, in
from .ciscoconfparse import CiscoConfParse
File "C:\Users\sagarpa\PycharmProjects\Project1\venv\lib\site-packages\ciscoconfparse\ciscoconfparse.py", line 5536

^

SyntaxError: invalid syntax

i am receiving the same error
windows 10
python 3.7.0

error:
Traceback (most recent call last):
File "asa-extract-obj.py", line 1, in
from ciscoconfparse import CiscoConfParse
File "C:\python\lib\site-packages\ciscoconfparse_init_.py", line 1, in
from .ciscoconfparse import *
File "C:\python\lib\site-packages\ciscoconfparse\ciscoconfparse.py", line 5536

^

SyntaxError: invalid syntax

i just confirmed it is happening with all lines which are split using the "\".

for example in ccp_util.py:
` return (self.network<=val.network) and \

                (self.broadcast>=val.broadcast)`

if i change to a single line as follows, the error goes away:
return (self.network<=val.network) and (self.broadcast>=val.broadcast)

Python 3.7 is not tested or supported right now; I can confirm that something changed about Python3.7, but I don't know what yet.

I also confirmed that I can "pip3.exe install -U ciscoconfparse" and there is no issue with Python3.6 under Windows. Please download Python3.6.x from python.org:

https://www.python.org/downloads/windows/

It is working fine with Python 3.6.x.

Thank you.

Perhaps this should be mentioned in the README, which currently states in two places that Python 3.2+ is supported.

I am seeing the same issue under a fresh install of Python 3.7.0, under Windows 10 x64; ciscoconfparse was installed using pip.

It seems that during download, something (pip?) adds a new, empty, line after every single line of code in the .py files (the sshot in the original issue report shows this very nicely). While this is not a problem for most lines, it does cause errors on lines that were split using ''.

I have managed to fix this manually by removing the empty lines in the ciscoconfparse files (in lib\site-packages\ciscoconfparse).

Amazingly, not all of the files have been affected. Some of them (like protocol_values.py, or models_asa.py) were OK. Others, however (ciscoconfparse.py, models_cisco.py, models_nxos.py, ccp_abc.py, ccp_util.py, etc) were exhibiting the issue.

I just downloaded Python3.7.1 on x64 (Windows 10), then ran pip3 install -U ciscoconfparse. I had no problems with 3.7.1.

Please note: Before I installed 3.7.1, I completely uninstalled and deleted the original Python 3.7.0 windows directory. In my case, Python3.7 was installed in "C:\Users\mpenning\AppData\Local\Programs\Python\Python37".

Please try uninstalling Python 3.7.0, delete the residual directories, then reinstall with Python 3.7.1.

for example in ccp_util.py:
` return (self.network<=val.network) and \

                (self.broadcast>=val.broadcast)`

if i change to a single line as follows, the error goes away:
return (self.network<=val.network) and (self.broadcast>=val.broadcast)

Fresh installation did not work for me. Removing "/" from couple of files worked for me

I tried 3.7.0, 3.7.1, 3.7.2

I installed Python for Windows 10 x64 version 3.7.2... then, I used pip3 to install ciscoconfparse.

I still cannot reproduce the problems you're asking about...

image

@mpenning
Surprisingly, even i am not able to reproduce it.
This time it not giving any error for the below syntax
return (self.network<=val.network) and \ (self.broadcast>=val.broadcast)
Last time it was not liking this ' \ ' multi line syntax. When i removed the multi line and put it in single line it was working.
Anyways, now i think it is working with multi line as well. So, i would say i am good. Thank you very much to look into it.