繁体   English   中英

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

[英]error to install pip install psycopg2 on fedora 23

我会做这些事情已经有一段时间了

 ➜  ~  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)➜ edu pip 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

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

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

Python 2.x:

sudo dnf install python-devel

Python 3.x:

sudo dnf install python3-devel

第 1 步:对于 rpm linux

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

用于 deb linux

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

第 2 步:在你的virtualenv

pip install psycopg2

试试这个,它对我有用 我正在使用 Fedora 33

pip install psycopg2-binary

运行此命令对我有用

sudo dnf install python3-devel

暂无
暂无

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

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