在 OS X 上使用 pip 安装 bcrypt 时出错:找不到 ffi.h(安装了 libffi) [英] Error installing bcrypt with pip on OS X: can't find ffi.h (libffi is installed)

查看:21
本文介绍了在 OS X 上使用 pip 安装 bcrypt 时出错:找不到 ffi.h(安装了 libffi)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用 pip 安装 bcrypt 时遇到此错误.我在几个地方(Xcode OS X SDK 和自制软件)安装了 libffi,但我不知道如何告诉 pip 查找它.有什么建议吗?

I'm getting this error when trying to install bcrypt with pip. I have libffi installed in a couple places (the Xcode OS X SDK, and from homebrew), but I don't know how to tell pip to look for it. Any suggestions?

Downloading/unpacking bcrypt==1.0.2 (from -r requirements.txt (line 41))
  Running setup.py egg_info for package bcrypt
    OS/X: confusion between 'cc' versus 'gcc' (see issue 123)
    will not use '__thread' in the C code
    c/_cffi_backend.c:14:10: fatal error: 'ffi.h' file not found
    #include <ffi.h>
             ^
    1 error generated.
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/Users/cody/virtualenvs/analytics/build/bcrypt/setup.py", line 104, in <module>
        "Programming Language :: Python :: 3.3",
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 112, in setup
        _setup_distribution = dist = klass(attrs)
      File "build/bdist.macosx-10.9-intel/egg/setuptools/dist.py", line 239, in __init__
      File "build/bdist.macosx-10.9-intel/egg/setuptools/dist.py", line 264, in fetch_build_eggs
      File "build/bdist.macosx-10.9-intel/egg/pkg_resources.py", line 620, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "build/bdist.macosx-10.9-intel/egg/pkg_resources.py", line 858, in best_match
        return self.obtain(req, installer) # try and download/install
      File "build/bdist.macosx-10.9-intel/egg/pkg_resources.py", line 870, in obtain
        return installer(requirement)
      File "build/bdist.macosx-10.9-intel/egg/setuptools/dist.py", line 314, in fetch_build_egg
      File "build/bdist.macosx-10.9-intel/egg/setuptools/command/easy_install.py", line 593, in easy_install

      File "build/bdist.macosx-10.9-intel/egg/setuptools/command/easy_install.py", line 623, in install_item

      File "build/bdist.macosx-10.9-intel/egg/setuptools/command/easy_install.py", line 811, in install_eggs

      File "build/bdist.macosx-10.9-intel/egg/setuptools/command/easy_install.py", line 1017, in build_and_install

      File "build/bdist.macosx-10.9-intel/egg/setuptools/command/easy_install.py", line 1005, in run_setup

    distutils.errors.DistutilsError: Setup script exited with error: command 'cc' failed with exit status 1
    Complete output from command python setup.py egg_info:
    OS/X: confusion between 'cc' versus 'gcc' (see issue 123)

will not use '__thread' in the C code

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

#include <ffi.h>

         ^

1 error generated.

Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/Users/cody/virtualenvs/analytics/build/bcrypt/setup.py", line 104, in <module>

    "Programming Language :: Python :: 3.3",

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 112, in setup

    _setup_distribution = dist = klass(attrs)

  File "build/bdist.macosx-10.9-intel/egg/setuptools/dist.py", line 239, in __init__

  File "build/bdist.macosx-10.9-intel/egg/setuptools/dist.py", line 264, in fetch_build_eggs

  File "build/bdist.macosx-10.9-intel/egg/pkg_resources.py", line 620, in resolve

    dist = best[req.key] = env.best_match(req, ws, installer)

  File "build/bdist.macosx-10.9-intel/egg/pkg_resources.py", line 858, in best_match

    return self.obtain(req, installer) # try and download/install

  File "build/bdist.macosx-10.9-intel/egg/pkg_resources.py", line 870, in obtain

    return installer(requirement)

  File "build/bdist.macosx-10.9-intel/egg/setuptools/dist.py", line 314, in fetch_build_egg

  File "build/bdist.macosx-10.9-intel/egg/setuptools/command/easy_install.py", line 593, in easy_install



  File "build/bdist.macosx-10.9-intel/egg/setuptools/command/easy_install.py", line 623, in install_item



  File "build/bdist.macosx-10.9-intel/egg/setuptools/command/easy_install.py", line 811, in install_eggs



  File "build/bdist.macosx-10.9-intel/egg/setuptools/command/easy_install.py", line 1017, in build_and_install



  File "build/bdist.macosx-10.9-intel/egg/setuptools/command/easy_install.py", line 1005, in run_setup



distutils.errors.DistutilsError: Setup script exited with error: command 'cc' failed with exit status 1

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /Users/cody/virtualenvs/analytics/build/bcrypt

推荐答案

不使用 sudo 和 CFLAGS 和 CPPFLAGS(pip 不需要):

Without using sudo and CFLAGS and CPPFLAGS (unnecessary for pip):

$ brew install pkg-config libffi
$ export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.0.13/lib/pkgconfig/
$ pip install bcrypt

这篇关于在 OS X 上使用 pip 安装 bcrypt 时出错:找不到 ffi.h(安装了 libffi)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆