0

i installed lib: googleapis-common-protos 1.6.0 grpcio 1.22.0 grpcio-tools 1.22.0

i run a simple demo,then an exception occurs:

grpclib/grpcapi.py:1: in import grpc /usr/local/lib/python3.7/site-packages/grpc/init.py:24: in from grpc import _compression /usr/local/lib/python3.7/site-packages/grpc/_compression.py:17: in NoCompression = cygrpc.CompressionAlgorithm.none E AttributeError: module 'grpc._cython.cygrpc' has no attribute 'CompressionAlgorithm'

i try grpcio==1.21.1 grpcio-tools==1.21.1,it doesn't work. but it works in python2.7. however i must run it in python 3.6+

here is the proto file:

syntax = "proto3";

option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
option objc_class_prefix = "HLW";

package demo;

service mrpc_service {
  rpc call (mrpc_request) returns (mrpc_reply) {}
}

message mrpc_request {
  string action = 1;
  string body = 2;
}

message mrpc_reply {
  string result = 1;
  string body = 2;
}

Please help, thanks!

Ali Zwd
  • 145
  • 2
  • 4

3 Answers3

0

The C extension of your grpcio package seems not installed correctly. Can you post your pip log for installation? Also, I would like to know what OS are you using?

This bug may need more context to debug. Can you consider file an issue to gRPC repo? https://github.com/grpc/grpc

Lidi Zheng
  • 1,801
  • 8
  • 13
0

finally,i found the culprit; i use pytest, and add pytest.ini like:

[pytest]
filterwarnings =
    error
    ignore::UserWarning

remove, then it works. wtf!

Ali Zwd
  • 145
  • 2
  • 4
  • note you should note your "error" and "ignore::UserWarning" are in the wrong order. filterwarnings directives are processed in order from top to bottom and your "ignore::UserWarning" will have no effect – Thomas Grainger Dec 06 '19 at 16:53
0

This appears to be fixed now in pytest 5.3 or more https://github.com/pytest-dev/pytest/issues/6314

Thomas Grainger
  • 2,271
  • 27
  • 34