首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何安装psycopg2,fro,Fedora

如何安装psycopg2,fro,Fedora
EN

Stack Overflow用户
提问于 2019-09-28 08:36:56
回答 3查看 2.5K关注 0票数 3

当我试图安装psycopg2 pip install psycopg2时会出现错误

我不知道我是否有pg_config。我试着找出pg_config在哪里,psql。但是当我安装了pg_config (11.4)时,我不明白为什么系统中没有PostgreSQL。如果它在系统中,如何设置路径,使psycopg2安装成为可能。

代码语言:javascript
运行
复制
(myvenv) [jpsofficedev@localhost djangogirls]$ postgres --version
postgres (PostgreSQL) 11.4
(myvenv) [jpsofficedev@localhost djangogirls]$ echo $PATH
/home/jpsofficedev/Documents/coding_for_girls/djangogirls/myvenv/bin:/home/jpsofficedev/.local/bin:/home/jpsofficedev/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/var/lib/snapd/snap/bin:/Library/PostgreSQL/11.4/bin
(myvenv) [jpsofficedev@localhost djangogirls]$ which psql
/usr/bin/psql
(myvenv) [jpsofficedev@localhost djangogirls]$ which pg_config
/usr/bin/which: no pg_config in (/home/jpsofficedev/Documents/coding_for_girls/djangogirls/myvenv/bin:/home/jpsofficedev/.local/bin:/home/jpsofficedev/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/var/lib/snapd/snap/bin:/Library/PostgreSQL/11.4/bin)
代码语言:javascript
运行
复制
Collecting psycopg2
  Using cached https://files.pythonhosted.org/packages/5c/1c/6997288da181277a0c29bc39a5f9143ff20b8c99f2a7d059cfb55163e165/psycopg2-2.8.3.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /home/jpsofficedev/Documents/coding_for_girls/djangogirls/myvenv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-w3r253fu/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-w3r253fu/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /tmp/pip-install-w3r253fu/psycopg2/
    Complete output (23 lines):
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'

    Error: pg_config executable not found.

    pg_config is required to build psycopg2 from source.  Please add the directory
    containing pg_config to the $PATH or specify the full executable path with the
    option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    If you prefer to avoid building psycopg2 from source, please install the PyPI
    'psycopg2-binary' package instead.

    For further information please check the 'doc/src/install.rst' file (also at
    <http://initd.org/psycopg/docs/install.html>).

    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 19.2.2, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
EN

回答 3

Stack Overflow用户

发布于 2022-09-10 18:00:07

这对我来说很管用

代码语言:javascript
运行
复制
sudo yum install python-devel postgresql-devel rpm-build
pip install psycopg2
票数 0
EN

Stack Overflow用户

发布于 2022-10-01 16:32:24

根据其中一位用户的建议,我使用了这些命令,并且对我起了作用。

代码语言:javascript
运行
复制
 sudo dnf install python-devel postgresql-devel rpm-build
 pip install psycopg2
票数 0
EN

Stack Overflow用户

发布于 2022-06-16 18:54:02

OP把这个作为评论。这对我也有用。如果你把这作为一个答案,那将是最好的。

sudo yum install libpq-devel python-devel

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58144684

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档