nokia / pygnmi

Python tools for gNMI
MIT License
28 stars 7 forks source link

Problem running code #3

Closed kb70 closed 6 years ago

kb70 commented 6 years ago

Hi, I wanted to get familiar with the options I have in regards to the gRPC interface of the 7750 SRs, apart from NSP. Delighted I found your python code, but unfortunately I am not able to get it working. Following your instructions I get "No module named 'github.com'". I tried various things, playing around with import statements, but to no avail.

Environment: Debian9.3, Python 3.4.2 (virtualenv), grpcio (1.10.0), grpcio-tools (1.10.0)

Thanks.

wisotzky commented 6 years ago

This error message does not make much sense from my point of view. Have you followed the installation description from? https://github.com/nokia/pygnmi/blob/master/README.md

Typically I am using python2.7 in my environment - but I am not aware about issues using py3.

kb70 commented 6 years ago

Hmm, I don't know what I'm doing wrong. I tried on another Box[1], but get a similar error: 18/03/13 08:40:53,153 No module named github.com.openconfig.gnmi.proto.gnmi_ext

It seems my environment is not able to import a lib directly from github. Am I missing any lib, that makes this possible? Googling for 'python import github' gives a lot of results, even dedicated libs.

Thanks for your help.

[1]

metrics:~/nokia/pygnmi# python --version
Python 2.7.12
metrics:~/nokia/pygnmi# pip list
enum34 (1.1.6)
futures (3.2.0)
grpcio (1.10.0)
pip (9.0.1)
protobuf (3.5.2)
setuptools (20.7.0)
six (1.11.0)
wheel (0.29.0)
wisotzky commented 6 years ago

Just did some validation... I've identified the root-cause of this issue: On February 3rd a new version of gNMI was released: 0.6.0

My installation recipe is taking shortcuts, to avoid compiling the gnmi.proto file yourself. So I've proposed just to take the latest version of the gnmi_pb2.py from GitHub.

Seems this approach is not working anymore as Rob has refactored gNMI while gnmi.proto is now importing another file called gnmi_ext.proto: import "github.com/openconfig/gnmi/proto/gnmi_ext/gnmi_ext.proto";

In conclusion, python can not resolve the dependency (finding the auto-generated gnmi_ext_pb2.py).

I have not yet looked into the differences between gNMI version 0.4, 0.5 and 0.6... So the safest option is likely to copy the older version of gnmi_pb2. This should make it running...

Solution: # curl -O https://raw.githubusercontent.com/openconfig/gnmi/c5b444cd3ab8af669d0b8934f47a41ed6a985cdc/proto/gnmi/gnmi_pb2.py

Or use wget instead...

wisotzky commented 6 years ago

Will update the README accordingly.

kb70 commented 6 years ago

That worked. Thanks a lot for your help.

wisotzky commented 6 years ago

Gut das es funktioniert!

Please note, that I've tested this version against SROS 15.1 (gnmi 0.4)... So if you are using an older release, you likely experience issues because 0.4 was introducing some fundamental changes regarding the path encoding - which have been implemented on Nokia nodes in an non-backward compatible way.

Still need to check the product roadmap for SROS 16.0 (May 2018) - if we plan to upgrade to either gNMI 0.5 or 0.6. In such case, I would consider to update the tool accordingly.

raja018 commented 5 years ago

Hello experts,

I am facing some issues running the pygnmi and getting an consistent error 19/08/31 05:09:49,696 No module named 'google'

I do not know how to verify the gnmi version