可以在MacOS Monterey上安装Psycopg2-Binary 12.3

发布于 2025-01-17 10:17:25 字数 1966 浏览 0 评论 0原文

我一直在尝试为我的Django项目安装Psycopg2-binary,到目前为止,什么都没有起作用。它一直要求pg_config文件,据我所知,只有在您构建psycopg2时才需要。那么,这里发生了什么?

Collecting psycopg2-binary
  Using cached psycopg2-binary-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/7t/15s08lqd0r51727h4ljk1bq00000gn/T/pip-pip-egg-info-03hv65aq/psycopg2_binary.egg-info
      writing /private/var/folders/7t/15s08lqd0r51727h4ljk1bq00000gn/T/pip-pip-egg-info-03hv65aq/psycopg2_binary.egg-info/PKG-INFO
      writing dependency_links to /private/var/folders/7t/15s08lqd0r51727h4ljk1bq00000gn/T/pip-pip-egg-info-03hv65aq/psycopg2_binary.egg-info/dependency_links.txt
      writing top-level names to /private/var/folders/7t/15s08lqd0r51727h4ljk1bq00000gn/T/pip-pip-egg-info-03hv65aq/psycopg2_binary.egg-info/top_level.txt
      writing manifest file '/private/var/folders/7t/15s08lqd0r51727h4ljk1bq00000gn/T/pip-pip-egg-info-03hv65aq/psycopg2_binary.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]

当然,PIP是其最新版本,我已经指定了pip install psycopg2-binary

我的Mac的拱门是ARM64。

任何帮助将不胜感激。谢谢

I've been trying to install psycopg2-binary for my django project, and so far nothing has been working. It keeps asking for the pg_config file, which to my knowledge is only required if you are building psycopg2. So, what is happening here?

Collecting psycopg2-binary
  Using cached psycopg2-binary-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/7t/15s08lqd0r51727h4ljk1bq00000gn/T/pip-pip-egg-info-03hv65aq/psycopg2_binary.egg-info
      writing /private/var/folders/7t/15s08lqd0r51727h4ljk1bq00000gn/T/pip-pip-egg-info-03hv65aq/psycopg2_binary.egg-info/PKG-INFO
      writing dependency_links to /private/var/folders/7t/15s08lqd0r51727h4ljk1bq00000gn/T/pip-pip-egg-info-03hv65aq/psycopg2_binary.egg-info/dependency_links.txt
      writing top-level names to /private/var/folders/7t/15s08lqd0r51727h4ljk1bq00000gn/T/pip-pip-egg-info-03hv65aq/psycopg2_binary.egg-info/top_level.txt
      writing manifest file '/private/var/folders/7t/15s08lqd0r51727h4ljk1bq00000gn/T/pip-pip-egg-info-03hv65aq/psycopg2_binary.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]

Of course, pip is at its latest version, and I've specified pip install psycopg2-binary.

My mac's arch is arm64.

Any help would be appreciated. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅暮の光 2025-01-24 10:17:25

psycopg2-binary 2.9.3 不提供 MacOS arm64 的二进制轮子; MacOS 的二进制轮仅适用于 Intel x86 64 位。因此,pip 尝试从源代码进行编译,但失败了。

要从源代码进行编译,您需要很多先决条件

psycopg2-binary 2.9.3 doesn't provide binary wheels for MacOS arm64; binary wheels for MacOS are only provided for Intel x86 64 bits. So pip tried to compile from sources — and failed.

To compile from sources you need a lot of prerequisites.

夜深人未静 2025-01-24 10:17:25

我在网上找到了这个,它对我有用:

❯ brew install postgresql

如果您打开一个新的终端选项卡,您会看到PG_Config可用

❯ export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"
❯ export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib -L${HOME}/.pyenv/versions/3.8.10/lib"

❯ python -V
Python 3.8.10
❯ pip install psycopg2-binary==2.8.6

I found this online and it worked for me:

❯ brew install postgresql

If you open a new terminal tab you will see that pg_config is available

❯ export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"
❯ export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib -L${HOME}/.pyenv/versions/3.8.10/lib"

❯ python -V
Python 3.8.10
❯ pip install psycopg2-binary==2.8.6
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文