error: command '/usr/bin/clang' failed with exit status 1

mac python3.6 运行 pip install psycopg2 一直报如下错误:

error: command '/usr/bin/clang' failed with exit status 1

经过一番查找,终于有了解决方案:

  • 1.首先执行
xcode-select --install

安装xcode的命令行工具,如果已存在则会提示:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

那么就可以忽略,继续下一步

    1. 然后手动将我自己安装的openssl链接到pip(未安装openssl的话可以通过Homebrew安装)
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install psycopg2

最后出现如下:

Collecting psycopg2
  Using cached https://files.pythonhosted.org/packages/5c/1c/6997288da181277a0c29bc39a5f9143ff20b8c99f2a7d059cfb55163e165/psycopg2-2.8.3.tar.gz
Installing collected packages: psycopg2
  Running setup.py install for psycopg2 ... done
Successfully installed psycopg2-2.8.3

则表示安装psycopg2成功。

你可能感兴趣的:(error: command '/usr/bin/clang' failed with exit status 1)