Macos – Pip install on Mac OS gets error: command ‘/usr/bin/clang’ failed with exit code 1

google-cloud-platformgoogle-cloud-pubsubmacospippython-3.x

I want to install google-cloud-pubsub via pip installation on Mac OS but I get an error: distutils.errors.CompileError: command '/usr/bin/clang' failed with exit code 1. The command I run: pip install google-cloud-pubsub==2.1.0.

Here the complete error message.

Any suggestion? Thank you!

More info:

$ python -V
Python 3.9.0

$ pip -V
pip 20.2.4 from /.../lib/python3.9/site-packages/pip (python 3.9)

$ sw_vers
ProductName:    macOS
ProductVersion: 11.0.1
BuildVersion:   20B29

I've seen other similar cases but them don't solve my issue. I tried:

Best Answer

Try to add these env var before

GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true pip install google-cloud-pubsub==2.1.0

If it does not work you can try with virtualenv:

pip install virtualenv
virtualenv my-test-env
source my-test-env/bin/activate
my-test-env/bin/pip install google-cloud-pubsub==2.1.0

Because is written on github:

Install this library in a virtualenv using pip. virtualenv is a tool to create isolated Python environments. The basic problem it addresses is one of dependencies and versions, and indirectly permissions.

With virtualenv, it's possible to install this library without needing system install permissions, and without clashing with the installed system dependencies.