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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27182042/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 01:30:45  来源:igfitidea点击:

pip error: unrecognized command line option ‘-fstack-protector-strong’

pythonpiplxmlcythonpyquery

提问by cooltoast

When I sudo pip install pyquery, sudo pip install lxml, and sudo pip install cython, I get very similar output with the same error that says:

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

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

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

Here's the complete pip output for sudo pip install pyquery:

这是完整的 pip 输出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

The complete log from /root/.pip/pip.log is here: http://pastebin.com/5R4VZDu8

/root/.pip/pip.log 的完整日志在这里:http://pastebin.com/5R4VZDu8

I've looked at this, this, this, and thisfor help, but I haven't been able to solve the issue yet.

我已经查看了thisthisthisthis以寻求帮助,但我还没有解决这个问题。

I've already installed libxml2-dev, libxslt1-dev, and python-dev. I'm running Debian 7.0 x64 on a DigitalOcean droplet.

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

I'm just trying to install pyquery. Can someone please help me out?

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

Thanks

谢谢

采纳答案by meyerson

I ran into this problem when I attempted to upgrade my pandas version to 0.15.2

当我尝试将我的 Pandas 版本升级到 0.15.2 时遇到了这个问题

If you install gcc-4.9 you are likely to still have an older version of gcc on your system (gcc-4.7 in my case).

如果您安装 gcc-4.9,您的系统上可能仍然有旧版本的 gcc(在我的例子中是 gcc-4.7)。

I can think of 3 ways to solve this issue:

我可以想到3种方法来解决这个问题:

a) symlink /usr/bin/x86_64-linux-gnu-gcc to /usr/bin/x86_64-linux-gnu-gcc-4.9 if you want to be more organized about this use update-alternatives, see https://askubuntu.com/questions/26498/choose-gcc-and-g-version

a) 将 /usr/bin/x86_64-linux-gnu-gcc 符号链接到 /usr/bin/x86_64-linux-gnu-gcc-4.9 如果您想对此使用更有条理,请使用update-alternatives,请参阅https://askubuntu .com/questions/26498/choose-gcc-and-g-version

b) figure out how to manually specify which compiler pip uses and set it in some sort of .conf file - I haven't examined where this file lives or if there are CLI options for pip that accomplish the equivalent. In principle, creating/editing a /usr/lib/pythonX.Y/distutils/distutils.cfg should do it. I ran into problems when I tried to use this approach.

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

c) Edit /usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata_nd.py to reflect your updated compiler

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

使用Pip安装Python包时如何使用MinGW的gcc编译器?https://docs.python.org/2/install/#distutils-configuration-files

I went with the quick and dirty solution (a) to force everything to work

我采用了快速而肮脏的解决方案 (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 . . . 

move things back to how they were

将事情恢复原状

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

回答by Sjoerd

One possible solution would be to use GCC 4.9 or higher, which does support the -fstack-protector-strongflag.

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

回答by user323094

Instead of upgrading to GCC 4.9, I was trying to find where the flag was defined and remove it. On Debian Wheezy, I found it in /usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata_nd.py which belongs to the libpython2.7-minimal package. My solution was to replace all occurrences of -fstack-protector-strong with -fstack-protector within this file. Then pip install executed the correct build command.

我没有升级到 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 执行了正确的构建命令。