Ali Zwd
Ali Zwd

Reputation: 173

why would i get AttributeError when run grpc demo in python3.7.4

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!

Upvotes: 0

Views: 3778

Answers (3)

Thomas Grainger
Thomas Grainger

Reputation: 2429

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

Upvotes: 0

Ali Zwd
Ali Zwd

Reputation: 173

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

[pytest]
filterwarnings =
    error
    ignore::UserWarning

remove, then it works. wtf!

Upvotes: 0

Lidi Zheng
Lidi Zheng

Reputation: 2091

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

Upvotes: 0

Related Questions