简体   繁体   English

Pip 在 Mac OS 上安装出现错误:命令“/usr/bin/clang”失败,退出代码为 1

[英]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 .我想在 Mac OS 上通过 pip 安装来安装 google-cloud-pubsub,但出现错误: distutils.errors.CompileError: command '/usr/bin/clang' failed with exit code 1 The command I run: pip install google-cloud-pubsub==2.1.0 .我运行的命令: 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:我试过了:

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:如果它不起作用,您可以尝试使用 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 :因为是写在github上的:

Install this library in a virtualenv using pip.使用 pip 在 vi​​rtualenv 中安装这个库。 virtualenv is a tool to create isolated Python environments. virtualenv 是一个创建隔离 Python 环境的工具。 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.使用 virtualenv,可以在不需要系统安装权限的情况下安装这个库,并且不会与已安装的系统依赖项发生冲突。

I just had this same problem but I'm using homebrew to manage my Mac packages.我刚刚遇到了同样的问题,但我正在使用自制软件来管理我的 Mac 包。 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:这可以通过安装 leveldb 使用自制软件来解决:

brew install leveldb

This allowed the plyvel dependency to be satisified.这允许满足 plyvel 依赖性。 I then manually installed plyvel just to be safe:然后为了安全起见,我手动安装了 plyvel:

pip3 install plyvel

And lastly because I'm trying to install the airflow libraries that include pubsub:最后,因为我正在尝试安装包含 pubsub 的气流库:

pip3 install apache-airflow-providers-google

Are you attempting to compile on a new M1 processor?您是否尝试在新的 M1 处理器上进行编译? I ran into trouble installing the latest grpcio (1.34.0) too, with the same error message as you.我在安装最新的 grpcio (1.34.0) 时也遇到了麻烦,错误消息与您相同。

Without messing with compile flags and libraries, I found the best solution for me (setting up a new Flask environment to talk to Google Cloud on a new Big Sur Mac) was the tip offered here:在不弄乱编译标志和库的情况下,我找到了最适合我的解决方案(设置一个新的 Flask 环境以在新的 Big Sur Mac 上与 Google Cloud 对话)是这里提供的提示:

https://osxdaily.com/2020/11/18/how-run-homebrew-x86-terminal-apple-silicon-mac/ https://osxdaily.com/2020/11/18/how-run-homebrew-x86-terminal-apple-silicon-mac/

  1. Duplicate your Terminal rename it to "Rosetta Terminal" or similar复制您的终端,将其重命名为“Rosetta Terminal”或类似名称
  2. Get Info on the new app, and check the box for "Open using Rosetta"获取有关新应用程序的信息,然后选中“使用 Rosetta 打开”复选框
  3. Do your work with this new terminal app instead改用这个新的终端应用程序做你的工作

grpcio installed fine for me this way, and I don't anticipate any problems running my Web apps in this translated environment (until I presume this issue gets fixed in the source libraries). grpcio 以这种方式为我安装得很好,而且我预计在这个翻译的环境中运行我的 Web 应用程序不会出现任何问题(直到我认为这个问题在源库中得到修复)。

if you are using Mac M1 chip, just do the below thing it worked for me.如果您使用的是 Mac M1 芯片,请执行以下对我有用的操作。

export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1

Thanks for the below answer.感谢以下回答。 How can I install GRPCIO on an Apple M1 Silicon laptop? 如何在 Apple M1 Silicon 笔记本电脑上安装 GRPCIO?

I ended up just using Python 3.8.13 instead, managed with pyenv and pyenv-virtualenv.我最终只使用了 Python 3.8.13,由 pyenv 和 pyenv-virtualenv 管理。

If you don't have pyenv:如果你没有 pyenv:

brew install pyenv pyenv-virtualenv

add添加

export PATH="$HOME/.pyenv/bin:$PATH"
export PATH="$HOME/.pyenv/shims:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

to your ~/.zshrc if it's not there, and source ~/.zshrc到你的 ~/.zshrc 如果它不存在, source ~/.zshrc

pyenv install 3.8.13
pyenv global 3.8.13
pyenv virtualenv 3.8.13 venv
pyenv activate venv
pip install grcpio

I encountered a similarly-named clang issue when attempting to awsiotsdk on an M1 Mac with Python 3.8我在使用 Python 3.8 的 M1 Mac 上尝试awsiotsdk时遇到了类似名称的clang问题

Incase it's relevant to anyone reading this, the underlying issue was a dependency on awscrt .如果它与阅读本文的任何人相关,则根本问题是对awscrt的依赖。 This particular library (on PyPi) did not contain Built Distributions for the combination of M1 ("xxx_universal2.whl") and Python 3.8.这个特定的库(在 PyPi 上)包含 M1(“xxx_universal2.whl”)和 Python 3.8 组合的内置发行版。

The solution was to use pyenv with pipenv (a favourite pattern of mine) to force this project to use a supported combination (in our case: Python 3.9 with M1 )解决方案是使用pyenvpipenv (我最喜欢的模式)来强制这个项目使用支持的组合(在我们的例子中: Python 3.9 和 M1

I was using pyenv and facing the similar kind of issue.我正在使用pyenv并面临类似的问题。 Then I did the following and it worked.然后我做了以下事情,它奏效了。

First, upgrade pip一、升级pip

pip3 install --upgrade pip

Then, update the setup tools:然后,更新设置工具:

python3 -m pip install --upgrade setuptools

Working solution in my case (Mac M1 Monterey OS):就我而言(Mac M1 Monterey OS)的工作解决方案:

brew install openssl re2
LDFLAGS="-L$(/opt/homebrew/bin/brew --prefix openssl)/lib -L$(/opt/homebrew/bin/brew --prefix re2)/lib" CPPFLAGS="-I$(/opt/homebrew/bin/brew --prefix openssl)/include -I$(/opt/homebrew/bin/brew --prefix re2)/include" GRPC_BUILD_WITH_BORING_SSL_ASM="" GRPC_PYTHON_BUILD_SYSTEM_RE2=true GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=true GRPC_PYTHON_BUILD_SYSTEM_ZLIB=true pip install grpcio

Credits to https://github.com/grpc/grpc/issues/24677#issuecomment-862413344归功于https://github.com/grpc/grpc/issues/24677#issuecomment-862413344

I started having that issue.我开始有那个问题。 Following this comment , with pyenv , I uninstalled my python 3.9.12 and reinstalled it again.这条评论之后,我使用pyenv卸载了我的 python 3.9.12 并再次重新安装。

I am having an M1 and macOS 12.6, btw.顺便说一句,我有 M1 和 macOS 12.6。

Deactivate your current virtualenv first, then:首先停用当前的virtualenv ,然后:

pyenv uninstall 3.9.12
pyenv install 3.9.12
pyenv local 3.9.12 # to set your local python version to the newly installed python
poetry shell
pip install grpcio # or poetry install grpcio

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pip3 install pgzero --- 导致命令“/usr/bin/gcc”失败,退出代码为 1(Python 3.9;macOS 10.15.7) - pip3 install pgzero --- leads to command '/usr/bin/gcc' failed with exit code 1 (Python 3.9; macOS 10.15.7) “Pip install”导致“错误:命令‘gcc’失败,退出状态为 1” - “Pip install” causing “error: command 'gcc' failed with exit status 1” pip3安装pyautogui失败,错误代码为1 Mac OS - pip3 install pyautogui fails with error code 1 Mac OS 通过 pip 错误(macos)安装瓶颈错误:瓶颈的构建轮失败; 错误:命令“gcc”失败,退出状态为 1 - install bottleneck by pip error (macos) ERROR: Failed building wheel for bottleneck; error: command 'gcc' failed with exit status 1 pip3 GDAL安装在命令“ python setup.py egg_info”上失败,错误代码为1 - pip3 GDAL install failed on Command “python setup.py egg_info” failed with error code 1 在 mac os 中的 pycharm 中使用 pip install dlib 时出错 - error while using pip install dlib in pycharm in mac os 安装pip3包。 退出状态1“命令'铿锵'失败” - Installing pip3 packages. Getting “command 'clang' failed with exit status 1” 错误:命令'x86_64-linux-gnu-gcc'在执行pip3安装python-geohash时失败,退出状态为1 - error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 while doing pip3 install python-geohash 执行 pip3 install tslearn 时出错 - 命令“x86_64-linux-gnu-gcc”失败,退出状态为 1 - Error doing pip3 install tslearn - command 'x86_64-linux-gnu-gcc' failed with exit status 1 pip install iconsdk:命令“ python setup.py egg_info”失败,错误代码为1 - pip install iconsdk: Command “python setup.py egg_info” failed with error code 1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM