【发布时间】:2022-07-20 14:57:19
【问题描述】:
我最近买了一台 MacBook Pro,并正在为一些 python 和 Django 编程设置它,但我最终在安装 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 却找不到任何东西,
欢迎任何帮助
谢谢
【问题讨论】:
-
您阅读了邮件吗?它告诉你你可以试试
psycopg2-binary。就 Python 而言,该软件包仍将安装psycopg2。 -
AKX 我确实尝试过,甚至我首先尝试安装 psycopg2-binary 之前只是 pscopg2,因为我确实在 windows 和 linux 中有一个环境,并且 linux 需要安装 psycopg2-binary 而不仅仅是 psycopg2。但是,是的,我试过了
-
“windows 和 Linux 中的环境”是什么意思?这与你的 MacBook 有什么关系? (是 Intel 机器还是 Apple Silicon?)
-
是的,它是苹果芯片,它是 M1,当我说环境时,我的意思是我的一切工作正常,一切都安装好并且工作正常,包括 psycopg2,我是 MacOS 新手,所以我正在为一些安装而苦苦挣扎
-
那么这个问题可能会有所帮助。我通过谷歌搜索
psycopg2 m1找到了它。 github.com/psycopg/psycopg2/issues/1286
标签: python-3.x django backend psycopg2