gpt4 book ai didi

postgresql - 如何为 linux、Fedora 安装 psycopg2

转载 作者:行者123 更新时间:2023-12-05 08:06:49 30 4
gpt4 key购买 nike

当我尝试安装 psycopg2 时出现错误pip 安装 psycopg2

我不知道我有没有pg_config。我尝试了这些以找出 pg_config、psql 在哪里。但我不明白当我安装了 PostgreSQL(11.4) 时,pg_config 是如何不在系统中的。如果它在系统中,如何设置 PATH 以便可以安装 psycopg2。

(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)

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.

最佳答案

这对我有用

sudo yum install python-devel postgresql-devel rpm-build
pip install psycopg2

关于postgresql - 如何为 linux、Fedora 安装 psycopg2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58144684/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com