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

寵の児 提交于 2019-11-29 09:21:12
meyerson

I ran into this problem when I attempted to upgrade my pandas version to 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).

I can think of 3 ways to solve this issue:

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

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.

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

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

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

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

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!