首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法在Mac12.3上安装psycopg2,我一直收到这个错误

无法在Mac12.3上安装psycopg2,我一直收到这个错误
EN

Stack Overflow用户
提问于 2022-03-26 19:41:15
回答 3查看 5.9K关注 0票数 5

我最近买了一款MacBook Pro,并为python编程做了准备,但我最后在安装psycopg2时遇到了问题,我已经尝试过几件事情了,但是没有一件对我有用,这里留下了错误,

代码语言:javascript
运行
复制
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的问题,但是找不到任何东西,

任何帮助都将受到欢迎

谢谢

EN

回答 3

Stack Overflow用户

发布于 2022-07-20 06:56:27

正如亚历克斯所提到的,是PostGreSQL没有安装在您的系统上,引发了错误安装PostGreSQL,并且所有这些都会很好地运行--尝试如下

代码语言:javascript
运行
复制
❯ 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```
票数 6
EN

Stack Overflow用户

发布于 2022-06-01 22:27:37

尝试使用以下命令:

代码语言:javascript
运行
复制
pip3 install psycopg2-binary
票数 4
EN

Stack Overflow用户

发布于 2022-06-10 02:47:32

很晚了,但我只是遇到了这个问题,没有什么能解决的。我试图在一台新Mac上安装一个正在进行的项目的requirements.txt。最后,我想起了这是一个postgresql包,我还没有安装postgresql。一旦我安装了postgresql并再次尝试安装psycopg2,它就可以正常工作,没有任何错误。

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

https://stackoverflow.com/questions/71631259

复制
相关文章

相似问题

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