找不到 pg_config 可执行文件
Cannot find pg_config executable
不知道 pg_config 是什么,我在网上搜索了一下,它似乎是 PostgreSQL 的一部分或与 PostgreSQL 相关联。虽然我没有或没有使用过,但我怀疑我可能会得到这个,因为我最近开始在 Python 中使用 azure 库(我以前从未遇到过这个问题)。这是错误消息之一:
WARNING: Discarding https://files.pythonhosted.org/packages/aa/8a/7c80e7e44fb1b4277e89bd9ca509aefdd4dd1b2c547c6f293afe9f7ffd04/psycopg2-2.9.1.tar.gz#sha256=de5303a6f1d0a7a34b9d40e4d3bef684ccc44a49bbe3eb85e3c0bffb4a131b7c (from https://pypi.org/simple/psycopg2/) (requires-python:>=3.6). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using cached psycopg2-2.9.tar.gz (379 kB)
Preparing metadata (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\E\AppData\Local\Programs\Python\Python310\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\E\AppData\Local\Temp\pip-install-q50_w0n5\psycopg2_b3e7f5e155154965bfc0d5340d85b1ff\setup.py'"'"'; __file__='"'"'C:\Users\E\AppData\Local\Temp\pip-install-q50_w0n5\psycopg2_b3e7f5e155154965bfc0d5340d85b1ff\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\E\AppData\Local\Temp\pip-pip-egg-info-ufqtnd89'
cwd: C:\Users\E\AppData\Local\Temp\pip-install-q50_w0n5\psycopg2_b3e7f5e155154965bfc0d5340d85b1ff\
Complete output (23 lines):
running egg_info
creating C:\Users\E\AppData\Local\Temp\pip-pip-egg-info-ufqtnd89\psycopg2.egg-info
writing C:\Users\E\AppData\Local\Temp\pip-pip-egg-info-ufqtnd89\psycopg2.egg-info\PKG-INFO
writing dependency_links to C:\Users\E\AppData\Local\Temp\pip-pip-egg-info-ufqtnd89\psycopg2.egg-info\dependency_links.txt
writing top-level names to C:\Users\E\AppData\Local\Temp\pip-pip-egg-info-ufqtnd89\psycopg2.egg-info\top_level.txt
writing manifest file 'C:\Users\E\AppData\Local\Temp\pip-pip-egg-info-ufqtnd89\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
<https://www.psycopg.org/docs/install.html>).
看来问题不在于路径,而在于我根本没有 pg_config。在线搜索没有帮助;我找到的建议是:
- 升级点数
- brew install postgresql(好像只适用于 mac???)
- pip 安装 psycopg2-binary
- 运行 其中 pg_config 运行
- whereis pg_config(也试过where)
None 有效。任何以 pg_config 开头的命令都表示这是一个无法识别的命令。
安装 PostgreSQL。从包安装时,确保安装包含 pg_config
、PGXS 和 C 头文件的开发包。
您可能需要将 PostgreSQL 二进制目录放在 PATH
:
export PATH=/usr/pgsql-14/bin:$PATH
(当然你要使用正确的路径。)
不知道 pg_config 是什么,我在网上搜索了一下,它似乎是 PostgreSQL 的一部分或与 PostgreSQL 相关联。虽然我没有或没有使用过,但我怀疑我可能会得到这个,因为我最近开始在 Python 中使用 azure 库(我以前从未遇到过这个问题)。这是错误消息之一:
WARNING: Discarding https://files.pythonhosted.org/packages/aa/8a/7c80e7e44fb1b4277e89bd9ca509aefdd4dd1b2c547c6f293afe9f7ffd04/psycopg2-2.9.1.tar.gz#sha256=de5303a6f1d0a7a34b9d40e4d3bef684ccc44a49bbe3eb85e3c0bffb4a131b7c (from https://pypi.org/simple/psycopg2/) (requires-python:>=3.6). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using cached psycopg2-2.9.tar.gz (379 kB)
Preparing metadata (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\E\AppData\Local\Programs\Python\Python310\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\E\AppData\Local\Temp\pip-install-q50_w0n5\psycopg2_b3e7f5e155154965bfc0d5340d85b1ff\setup.py'"'"'; __file__='"'"'C:\Users\E\AppData\Local\Temp\pip-install-q50_w0n5\psycopg2_b3e7f5e155154965bfc0d5340d85b1ff\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\E\AppData\Local\Temp\pip-pip-egg-info-ufqtnd89'
cwd: C:\Users\E\AppData\Local\Temp\pip-install-q50_w0n5\psycopg2_b3e7f5e155154965bfc0d5340d85b1ff\
Complete output (23 lines):
running egg_info
creating C:\Users\E\AppData\Local\Temp\pip-pip-egg-info-ufqtnd89\psycopg2.egg-info
writing C:\Users\E\AppData\Local\Temp\pip-pip-egg-info-ufqtnd89\psycopg2.egg-info\PKG-INFO
writing dependency_links to C:\Users\E\AppData\Local\Temp\pip-pip-egg-info-ufqtnd89\psycopg2.egg-info\dependency_links.txt
writing top-level names to C:\Users\E\AppData\Local\Temp\pip-pip-egg-info-ufqtnd89\psycopg2.egg-info\top_level.txt
writing manifest file 'C:\Users\E\AppData\Local\Temp\pip-pip-egg-info-ufqtnd89\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
<https://www.psycopg.org/docs/install.html>).
看来问题不在于路径,而在于我根本没有 pg_config。在线搜索没有帮助;我找到的建议是:
- 升级点数
- brew install postgresql(好像只适用于 mac???)
- pip 安装 psycopg2-binary
- 运行 其中 pg_config 运行
- whereis pg_config(也试过where)
None 有效。任何以 pg_config 开头的命令都表示这是一个无法识别的命令。
安装 PostgreSQL。从包安装时,确保安装包含 pg_config
、PGXS 和 C 头文件的开发包。
您可能需要将 PostgreSQL 二进制目录放在 PATH
:
export PATH=/usr/pgsql-14/bin:$PATH
(当然你要使用正确的路径。)