简体   繁体   English

无法在Linux上pip安装psycopg2

[英]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 尝试在Linux Mint上创建新的Heroku Python(Django)应用程序时,当pip尝试安装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. 1)错误是由我的系统上过时的gcc版本(4.8)引起的。 This verion does not support the '-fstack-protector-...' command line option. 此版本不支持'-fstack-protector -...'命令行选项。

2) I installed a newer version (4.9) as follows: 2)我安装了一个更新的版本(4.9),如下所示:

$ 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 3)我删除了/ usr / bin中的symlink x86_64-linux-gnu-gcc,并将其替换为新安装的gcc-4.9版本的symlink

$ 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 我花了一段时间才弄清楚,希望对其他人有帮助

Can't upvote DeBaze's answer (not enough rep). 无法提高DeBaze的答案(没有足够的代表)。 I'm using Ubuntu 16.02. 我正在使用Ubuntu 16.02。

I only needed to install the latest gcc and create the symlink ... 我只需要安装最新的gcc并创建符号链接...

sudo apt-get install gcc-4.9
sudo ln -s gcc-4.9 x86_64-linux-gnu-gcc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM