pip错误:无法识别的命令行选项'-fstack-protector-strong'

时间:2014-11-28 04:45:12

标签: python pip lxml cython pyquery

当我sudo pip install pyquerysudo pip install lxmlsudo pip install cython时,我会得到非常相似的输出,并显示相同的错误:

x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-fstack-protector-strong’

这里是sudo pip install pyquery的完整点子输出:

Requirement already satisfied (use --upgrade to upgrade): pyquery in /usr/local/lib/python2.7/dist-packages
Downloading/unpacking lxml>=2.1 (from pyquery)
  Running setup.py egg_info for package lxml
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    Building lxml version 3.4.1.
    Building without Cython.
    Using build configuration of libxslt 1.1.28

Requirement already satisfied (use --upgrade to upgrade): cssselect in /usr/local/lib/python2.7/dist-packages/cssselect-0.9.1-py2.7.egg (from pyquery)
Installing collected packages: lxml
  Running setup.py install for lxml
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    Building lxml version 3.4.1.
    Building without Cython.
    Using build configuration of libxslt 1.1.28
    building 'lxml.etree' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/libxml2 -I/root/build/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w
    x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-fstack-protector-strong’
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/root/build/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-gg4SuG-record/install-record.txt:
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'

  warnings.warn(msg)

Building lxml version 3.4.1.

Building without Cython.

Using build configuration of libxslt 1.1.28

running install

running build

running build_py

copying src/lxml/includes/lxml-version.h -> build/lib.linux-x86_64-2.7/lxml/includes

running build_ext

building 'lxml.etree' extension

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/libxml2 -I/root/build/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w

x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-fstack-protector-strong’

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/root/build/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-gg4SuG-record/install-record.txt failed with error code 1 in /root/build/lxml
Storing complete log in /root/.pip/pip.log

/root/.pip/pip.log中的完整日志位于:http://pastebin.com/5R4VZDu8

我已查看thisthisthisthis寻求帮助,但我无法解决问题爱好。

我已经安装了 libxml2-dev,libxslt1-dev和python-dev 。我在DigitalOcean Droplet上运行 Debian 7.0 x64

我只是想安装pyquery。有人可以帮帮我吗?

由于

3 个答案:

答案 0 :(得分:23)

当我尝试将我的pandas版本升级到0.15.2

时遇到了这个问题

如果您安装gcc-4.9,您的系统上可能仍会有旧版本的gcc(在我的情况下为gcc-4.7)。

我可以想出解决这个问题的3种方法:

a)symlink / usr / bin / x86_64-linux-gnu-gcc to /usr/bin/x86_64-linux-gnu-gcc-4.9 如果您想更有条理地使用 update-alternatives ,请参阅https://askubuntu.com/questions/26498/choose-gcc-and-g-version

b)弄清楚如何手动指定哪个编译器pip使用并在某种类型的.conf文件中设置它 - 我没有检查过这个文件的位置,或者是否有pip的CLI选项可以完成等价物。原则上,创建/编辑/usr/lib/pythonX.Y/distutils/distutils.cfg应该这样做。当我尝试使用这种方法时,我遇到了问题。

c)编辑/usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata_nd.py以反映您更新的编译器

How to use MinGW's gcc compiler when installing Python package using Pip? https://docs.python.org/2/install/#distutils-configuration-files

我选择快速而肮脏的解决方案(a)强制一切正常工作

root@localhost:/home/user1$ rm /usr/bin/x86_64-linux-gnu-gcc
root@localhost:/home/user1$ ln -s /usr/bin/gcc-4.9 /usr/bin/x86_64-linux-gnu-gcc
root@localhost:/home/user1$ pip install pandas --upgrade
. . .  pandas compiles with gcc-4.9 here . . . 

将事情移回原来的

root@localhost:/home/user1$ rm /usr/bin/x86_64-linux-gnu-gcc
root@localhost:/home/user1$ ln -s /usr/bin/gcc-4.7 /usr/bin/x86_64-linux-gnu-gcc

答案 1 :(得分:3)

一种可能的解决方案是使用GCC 4.9或更高版本,它支持-fstack-protector-strong标志。

答案 2 :(得分:3)

我没有升级到GCC 4.9,而是试图找到定义标志的位置并将其删除。在Debian Wheezy上,我在/usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata_nd.py中找到它,它属于libpython2.7-minimal包。我的解决方案是在此文件中用-fstack-protector替换所有出现的-fstack-protector-strong。然后pip install执行了正确的构建命令。