【问题标题】:Python compilation error: "LONG_BIT definition appears wrong for platform"Python 编译错误:“平台的 LONG_BIT 定义出现错误”
【发布时间】:2017-08-31 07:13:09
【问题描述】:

这个错误信息不是未知的,我已经重新安装了很多包,但目前还没有找到解决办法。

我从命令pip install cryptography得到以下错误

/usr/include/python2.7/pyport.h:849:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."

#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."

^

在长回溯结束时它说:

distutils.errors.DistutilsError: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-xXOpFq-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/cryptography
Storing debug log for failure in /root/.pip/pip.log

存在python-dev、python2.7-dev和python3-dev。

【问题讨论】:

  • 请使用有意义的标题。你的说(从 gobbledygook 翻译)“有一个编译错误”。
  • 关于问题本身,您需要跟踪LONG_BITSIZEOF_LONG 的定义位置。应该很迷人。对于 64 位系统,LONG_BIT 应该是 64,SIZEOF_LONGsizeof(long) 应该是 8。LONG_BIT 应该依赖于 limits.h 中的 LONG_MAX,并且 SIZEOF_LONG 应该在 pyconfig.h 中定义。
  • "python3-dev exists" :除非使用 pip3 命令,否则不相关。 ...您的操作系统未知。可能是 Ubuntu 15.10 吗?不能是 Debian 8:cryptography 已与 python-all-dev 一起安装。 ...刚刚使用五个不同的操作系统运行pip install cryptography 安装测试:完全没有问题。 ...
  • 在 /usr/include/python2.7/pyconfig.h 中定义为 SIZEOF_LONG 4。但是在 /usr/include/x86_64-linux-gnu/python2.7/pyconfig.h 中定义了SIZEOF_LONG 8

标签: python linux ubuntu gcc


【解决方案1】:

确保您为 python 安装了正确的位。 在我的情况下,我在我的 64 位 centO 上安装了 anaconda python 32 位,这导致了这个问题。为 Python 安装正确的位版本修复了它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-01
    • 1970-01-01
    相关资源
    最近更新 更多