在fedora 23上安装pip install psycopg2时出错

时间:2016-01-03 23:40:58

标签: python c++ linux python-2.7 fedora

我会做一段时间,我正在做这些事情

 ➜  ~  cd ~/project

    ➜  project  source vProject/bin/activate

    (vProject)➜  project  cd edu

    (vProject)➜  edu  pip install pillow

    Requirement already satisfied (use --upgrade to upgrade): pillow in /home/hadi/project/vProject/lib/python2.7/site-packages
  

我安装psycopg2的时刻

(vProject)➜edupip install psycopg2

我收到了这个错误

Collecting psycopg2
      Using cached psycopg2-2.6.1.tar.gz
    Building wheels for collected packages: psycopg2
      Running setup.py bdist_wheel for psycopg2
      Complete output from command /home/hadi/project/vProject/bin/python -c "import setuptools;__file__='/tmp/pip-build-K4RBgE/psycopg2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmp_YVqgFpip-wheel-:
      running bdist_wheel
      ...

      In file included from psycopg/psycopgmodule.c:27:0:
      ./psycopg/psycopg.h:31:22: fatal error: libpq-fe.h: No such file or directory
      compilation terminated.
      error: command 'gcc' failed with exit status 1

      ----------------------------------------
      Failed building wheel for psycopg2
    Failed to build psycopg2
    Installing collected packages: psycopg2
      Running setup.py install for psycopg2
        Complete output from command /home/hadi/project/vProject/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-K4RBgE/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-mKANSq-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/hadi/project/vProject/include/site/python2.7/psycopg2:
        running install
        running build
        running build_py
        running build_ext
        building 'psycopg2._psycopg' extension
        gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.1 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090405 -DHAVE_LO64=1 -I/usr/include/python2.7 -I. -I/usr/include -I/usr/include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-2.7/psycopg/psycopgmodule.o -Wdeclaration-after-statement

        In file included from psycopg/psycopgmodule.c:27:0:

        ./psycopg/psycopg.h:31:22: fatal error: libpq-fe.h: No such file or directory
        compilation terminated.

        error: command 'gcc' failed with exit status 1

        ----------------------------------------
    Command "/home/hadi/project/vProject/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-K4RBgE/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-mKANSq-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/hadi/project/vProject/include/site/python2.7/psycopg2" failed with error code 1 in /tmp/pip-build-K4RBgE/psycopg2

我之前已经安装了gcc

4 个答案:

答案 0 :(得分:6)

您缺少一个安装它所需的库。我相信您需要安装的软件包是postgresql-devel

答案 1 :(得分:2)

根据您在virtualenv中运行的Python版本,运行以下命令之一:

Python 2.x:

sudo dnf install python-devel

Python 3.x:

sudo dnf install python3-devel

答案 2 :(得分:2)

第1步: 对于rpm linux

sudo dnf install python-devel postgresql-devel rpm-build

for deb linux

sudo apt-get install libpq-dev python-dev build-essential

第2步: 你内心virtualenv

pip install psycopg2

答案 3 :(得分:0)

试试这个,它对我有用,我使用的是 Fedora 33

nvm use default 12.x or nvm alias default 12.x