【问题标题】:pip cffi package installation failed on osx在 osx 上 pip cffi 包安装失败
【发布时间】:2015-02-28 15:50:32
【问题描述】:

我正在为密码学和 Jasmin 安装安装 cffi 包。

我在发布问题之前做了一些研究,所以我找到了以下选项,但似乎不起作用:

系统

Mac OSx 10.9.5

python2.7

错误

c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found

#include <ffi.h>

         ^

1 warning and 1 error generated.

请指导我解决以下问题。

谢谢

命令

env DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib/ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" LDFLAGS="-L/usr/local /opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" sudo -E pip install cffi

日志

bhushanvaiude$ env DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib/ ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" sudo -E pip install cffi
Password:
Downloading/unpacking cffi
  Downloading cffi-0.8.6.tar.gz (196kB): 196kB downloaded
  Running setup.py egg_info for package cffi
    warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
    1 warning generated.
    
Downloading/unpacking pycparser (from cffi)
  Downloading pycparser-2.10.tar.gz (206kB): 206kB downloaded
  Running setup.py egg_info for package pycparser
    
Installing collected packages: cffi, pycparser
  Running setup.py install for cffi
    warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
    1 warning generated.
    building '_cffi_backend' extension
    cc -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -I/usr/local/opt/openssl/include -Qunused-arguments -pipe -Wno-error=unused-command-line-argument-hard-error-in-future -DUSE__THREAD -I@@HOMEBREW_CELLAR@@/libffi/3.0.13/lib/libffi-3.0.13/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c c/_cffi_backend.c -o build/temp.macosx-10.9-intel-2.7/c/_cffi_backend.o
    warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
    c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found
    #include <ffi.h>
             ^
    1 warning and 1 error generated.
    error: command 'cc' failed with exit status 1
    Complete output from command /Users/****project path***/bin/python -c "import setuptools;__file__='/Users/****project path***/build/cffi/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/7w/8z_mn3g120n34bv0w780gnd00000gn/T/pip-e6d6Ay-record/install-record.txt --single-version-externally-managed --install-headers /Users/****project path***/include/site/python2.7:
    warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]

1 warning generated.

running install

running build

running build_py

creating build

creating build/lib.macosx-10.9-intel-2.7

creating build/lib.macosx-10.9-intel-2.7/cffi

copying cffi/__init__.py -> build/lib.macosx-10.9-intel-2.7/cffi

copying cffi/api.py -> build/lib.macosx-10.9-intel-2.7/cffi

copying cffi/backend_ctypes.py -> build/lib.macosx-10.9-intel-2.7/cffi

copying cffi/commontypes.py -> build/lib.macosx-10.9-intel-2.7/cffi

copying cffi/cparser.py -> build/lib.macosx-10.9-intel-2.7/cffi

copying cffi/ffiplatform.py -> build/lib.macosx-10.9-intel-2.7/cffi

copying cffi/gc_weakref.py -> build/lib.macosx-10.9-intel-2.7/cffi

copying cffi/lock.py -> build/lib.macosx-10.9-intel-2.7/cffi

copying cffi/model.py -> build/lib.macosx-10.9-intel-2.7/cffi

copying cffi/vengine_cpy.py -> build/lib.macosx-10.9-intel-2.7/cffi

copying cffi/vengine_gen.py -> build/lib.macosx-10.9-intel-2.7/cffi

copying cffi/verifier.py -> build/lib.macosx-10.9-intel-2.7/cffi

running build_ext

building '_cffi_backend' extension

creating build/temp.macosx-10.9-intel-2.7

creating build/temp.macosx-10.9-intel-2.7/c

cc -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -I/usr/local/opt/openssl/include -Qunused-arguments -pipe -Wno-error=unused-command-line-argument-hard-error-in-future -DUSE__THREAD -I@@HOMEBREW_CELLAR@@/libffi/3.0.13/lib/libffi-3.0.13/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c c/_cffi_backend.c -o build/temp.macosx-10.9-intel-2.7/c/_cffi_backend.o

warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]

c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found

#include <ffi.h>

         ^

1 warning and 1 error generated.

error: command 'cc' failed with exit status 1

----------------------------------------
Cleaning up...

【问题讨论】:

标签: python macos pip python-cffi


【解决方案1】:

在你的终端尝试运行:

xcode-select --install

然后尝试再次安装该软件包。

默认情况下,XCode 将自身安装为 IDE,并且不设置环境供命令行工具使用;例如,/usr/include 文件夹将丢失。

运行上述命令将安装从命令行运行编译所需的工具并创建所需的符号链接。由于 Python 包使用 XCode 的命令行界面编译原生代码部分,因此安装包含原生组件的 Python 包需要此步骤。

每次 XCode 安装/升级时,您只需执行一次此操作,或者如果您看到类似的错误。

【讨论】:

  • 你能解释一下吗?
  • 这似乎设置了用于使用 Xcode 进行开发的命令行工具。这是一个很好的提示。
  • 为我工作...不知道为什么这是一个要求:)
  • 值得注意的是,每次 OS X 升级都会发生这种情况。也许 Xcode 更新通常需要更新最新版本的 OS X。
【解决方案2】:

安装 CLI 开发工具链与

$ xcode-select --install

如果您的 pkg-config 损坏,请使用 cmets 中提到的以下命令将其取消链接。

$ brew unlink pkg-config

安装 libffi 包

$ brew install pkg-config libffi

然后安装cffi

$ pip install cffi

来源:Error installing bcrypt with pip on OS X: can't find ffi.h (libffi is installed)

【讨论】:

  • 你值得向我的朋友致敬!
  • 我首先必须“brew unlink pkg-config”,然后按照您的说明进行操作,效果很好。
  • brew install pkg-config libffi 然后pip install cffi 是我所需要的。谢谢!
【解决方案3】:

在终端中运行以下命令解决了我的问题。

xcode-select --install

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-07
    • 2020-09-16
    • 1970-01-01
    • 2015-07-05
    • 2021-01-28
    • 2015-05-23
    相关资源
    最近更新 更多