ImportError: cannot import name GRPCError from grpclib when running modal setup

python3 -m modal setup failed with ImportError: cannot import name 'GRPCError' from 'grpclib' even after pip install --upgrade grpclib reported 0.4.7. The maintainer dug in and found the smoking gun: pip show grpclib in the broken environment had an empty Summary and no PyPI metadata, meaning some other package had shadowed the real grpclib install. The reporter confirmed everything worked in a fresh virtual environment with a clean pip install modal.

This import error with a supposedly correct grpclib version usually means the grpclib in your environment is not the real PyPI package. Run pip show grpclib and check for an empty Summary and missing metadata, which is the tell for a shadowed install. The reliable fix is a fresh virtual environment followed by a clean pip install modal, which pulls the pinned grpclib. Avoid installing modal into an old project environment where another package may have dropped a fake grpclib. Source: https://github.com/modal-labs/modal-client/issues/1634

Source: https://github.com/modal-labs/modal-client/issues/1634