Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip install on Mac OS gets error: command '/usr/bin/clang' failed with exit code 1

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:

  • Pip install error in Mac OS(error: command '/usr/bin/clang' failed with exit status 1)
  • Mac OS Mojave installation error - error: command 'clang' failed with exit status 1
like image 266
Fausto Fusaro Avatar asked Nov 17 '20 18:11

Fausto Fusaro


3 Answers

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.

like image 184
Gabouchet Avatar answered Oct 13 '22 22:10

Gabouchet


I just had this same problem but I'm using homebrew to manage my Mac packages. My error result was the same as yours but within the error message it was:

plyvel/_plyvel.cpp:632:10: fatal error: 'leveldb/db.h' file not found
#include "leveldb/db.h"

This can be fixed using homebrew by just installing leveldb:

brew install leveldb

This allowed the plyvel dependency to be satisified. I then manually installed plyvel just to be safe:

pip3 install plyvel

And lastly because I'm trying to install the airflow libraries that include pubsub:

pip3 install apache-airflow-providers-google
like image 3
Cory Brickner Avatar answered Oct 13 '22 23:10

Cory Brickner


I was using pyenv and facing the similar kind of issue. Then I did the following and it worked.

First, upgrade pip

pip3 install --upgrade pip

Then, update the setup tools:

python3 -m pip install --upgrade setuptools
like image 3
ARKhan Avatar answered Oct 13 '22 23:10

ARKhan