DeBaze DeBaze - 2 months ago 19
Python Question

Unable to pip install psycopg2 on linux

While trying to create a new Heroku Python (Django) app on Linux Mint I encounter following error when pip tries to install psycopg2

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

All dependencies are met (as explained in this question) so I don't see the problem here..


I have found the solution. It might be helpful for others as I didn't really find the answer online..

1) The error originates from an outdated gcc version (4.8) on my system. This verion does not support the '-fstack-protector-...' command line option.

2) I installed a newer version (4.9) as follows:

$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt-get install gcc-4.9

3) I removed the symlink x86_64-linux-gnu-gcc which was located in /usr/bin and replaced it with a symlink to the newly installed gcc-4.9 version

$ sudo rm x86_64-linux-gnu-gcc
$ sudo ln -s gcc-4.9 x86_64-linux-gnu-gcc

It took me a while to figure this out, I hope it helps others