我最近买了一款MacBook Pro,并为python编程做了准备,但我最后在安装psycopg2时遇到了问题,我已经尝试过几件事情了,但是没有一件对我有用,这里留下了错误,
Collecting psycopg2
Using cached psycopg2-2.9.3.tar.gz (380 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [23 lines of output]
running egg_info
creating /private/var/folders/7f/ssr40bmj6t3_yq0cv_43cttc0000gn/T/pip-pip-egg-info-noe7l09b/psycopg2.egg-info
writing /private/var/folders/7f/ssr40bmj6t3_yq0cv_43cttc0000gn/T/pip-pip-egg-info-noe7l09b/psycopg2.egg-info/PKG-INFO
writing dependency_links to /private/var/folders/7f/ssr40bmj6t3_yq0cv_43cttc0000gn/T/pip-pip-egg-info-noe7l09b/psycopg2.egg-info/dependency_links.txt
writing top-level names to /private/var/folders/7f/ssr40bmj6t3_yq0cv_43cttc0000gn/T/pip-pip-egg-info-noe7l09b/psycopg2.egg-info/top_level.txt
writing manifest file '/private/var/folders/7f/ssr40bmj6t3_yq0cv_43cttc0000gn/T/pip-pip-egg-info-noe7l09b/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>).
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
这表明它不是pip的问题,而是setup.py的问题,但是找不到任何东西,
任何帮助都将受到欢迎
谢谢
发布于 2022-07-20 06:56:27
正如亚历克斯所提到的,是PostGreSQL没有安装在您的系统上,引发了错误安装PostGreSQL,并且所有这些都会很好地运行--尝试如下
❯ brew install postgresql
# If you open a new terminal tab you will see that pg_config is available
❯ export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"
❯ export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib -L${HOME}/.pyenv/versions/3.8.10/lib"
❯ python -V
Python 3.9.13
❯ pip install psycopg2-binary==2.8.6```
发布于 2022-06-01 22:27:37
尝试使用以下命令:
pip3 install psycopg2-binary
发布于 2022-06-10 02:47:32
很晚了,但我只是遇到了这个问题,没有什么能解决的。我试图在一台新Mac上安装一个正在进行的项目的requirements.txt。最后,我想起了这是一个postgresql包,我还没有安装postgresql。一旦我安装了postgresql并再次尝试安装psycopg2,它就可以正常工作,没有任何错误。
https://stackoverflow.com/questions/71631259
复制相似问题