rules_docker icon indicating copy to clipboard operation
rules_docker copied to clipboard

ImportError: cannot import name 'cygrpc' from 'grpc._cython'

Open wsoesanto opened this issue 2 years ago • 1 comments

🐞 bug report

Affected Rule

py3_image

Is this a regression?

No, this issue has been occuring since #1561.

Description

A clear and concise description of the problem...

🔬 Minimal Reproduction

https://github.com/wsoesanto/docker_python

🔥 Exception or Error



Traceback (most recent call last):
  File "/app//main.binary.runfiles/__main__/main.py", line 1, in 
    import grpc
  File "/app/main.binary.runfiles/pypi_grpcio/site-packages/grpc/__init__.py", line 22, in 
    from grpc import _compression
  File "/app/main.binary.runfiles/pypi_grpcio/site-packages/grpc/_compression.py", line 20, in 
    from grpc._cython import cygrpc
ImportError: cannot import name 'cygrpc' from 'grpc._cython' 

🌍 Your Environment

Operating System:

  
$ uname -a
Darwin 192.168.1.5 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct  9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 arm64
  

Output of bazel version:

  
$ bazel version
Bazelisk version: development
Build label: 5.3.2
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Oct 19 18:35:48 2022 (1666204548)
Build timestamp: 1666204548
Build timestamp as int: 1666204548
  

Rules_docker version:

  
Using master as using other versions not working as well.
  

Anything else relevant?

wsoesanto avatar Dec 01 '22 11:12 wsoesanto

The problem is that bazel is happily copying the darwin compiled lib for grpc, instead of one compatible with your container's platform. Take a look here how to download the wheels that will work for you: https://github.com/bazelbuild/rules_python/pull/773#issuecomment-1202118678

You will probably want to use the multilinux_2_17 wheels.

jscheel avatar May 01 '23 05:05 jscheel