janakiramm / gRPC-Tutorial

Scripts and code for the tutorial published at The New Stack
http://thenewstack.io/grpc-lean-mean-communication-protocol-microservices
22 stars 13 forks source link

Python server not working #1

Open itaditya opened 6 years ago

itaditya commented 6 years ago

@janakiramm I followed all the steps till the point where we have to start the Python server.

On running python Calc_Server.py I'm getting the error ->

Traceback (most recent call last): File "Calc_Server.py", line 11, in class Calculator(Calc_pb2.CalculatorServicer): AttributeError: 'module' object has no attribute 'CalculatorServicer'

Versions -->

python (2.7.6)
grpcio (1.8.3)
grpcio-tools (1.8.3)
nafisfaysal commented 6 years ago

@itaditya You should carefully read the error message mate. The problem is the example code had some error. You need to import import Calc_pb2_grpc on Calc_Server.py and replace with the Calc_pb2_grpc.CalculatorServicer parameter of the Calculator Class. Then run python Calc_Server.py

Then go to the Calc_Client.py file and import Calc_pb2_grpc then replace with stub = Calc_pb2_grpc.CalculatorStub(channel) instead of stub = Calc_pb2.CalculatorStub(channel)

You can check out the final code here, https://github.com/nafisfaysal/gRPC-Tutorial

Thank you. -- Nafis