Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ciscoconfparse.py doesn't import under Python3.7.0 #117

Closed
sagarp123 opened this issue Aug 16, 2018 · 13 comments
Closed

ciscoconfparse.py doesn't import under Python3.7.0 #117

sagarp123 opened this issue Aug 16, 2018 · 13 comments

Comments

@sagarp123
Copy link

bug

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

@mpenning
Copy link
Owner

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

@sagarp123
Copy link
Author

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

@bradh11
Copy link

bradh11 commented Aug 25, 2018

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

@bradh11
Copy link

bradh11 commented Aug 25, 2018

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

@bradh11
Copy link

bradh11 commented Aug 25, 2018

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)

@mpenning
Copy link
Owner

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/

@mpenning mpenning changed the title Bug in ciscoconfparse.py file ciscoconfparse.py doesn't import under Python3.7 Aug 27, 2018
@sagarp123
Copy link
Author

It is working fine with Python 3.6.x.

Thank you.

@SA0TAY
Copy link

SA0TAY commented Sep 26, 2018

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

@bogd
Copy link

bogd commented Oct 21, 2018

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.

@mpenning mpenning changed the title ciscoconfparse.py doesn't import under Python3.7 ciscoconfparse.py doesn't import under Python3.7.0 Dec 15, 2018
@mpenning
Copy link
Owner

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.

@chiragvyas50
Copy link

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

@mpenning
Copy link
Owner

mpenning commented Feb 23, 2019

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

@chiragvyas50
Copy link

@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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants