【问题标题】:I can't install Psycopg2 with Python3 on Mac. I've installed Python3 and pip3我无法在 Mac 上使用 Python3 安装 Psycopg2。我已经安装了 Python3 和 pip3
【发布时间】:2019-10-10 01:00:23
【问题描述】:

我尝试输入以下命令: pip3 install --user psycopg2 psycopg2-binary

Bash 答案: 错误:正在运行安装

It appears you are missing some prerequisite to build the package from source.

You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.

For further information please check the 'doc/src/install.rst' file (also at
<http://initd.org/psycopg/docs/install.html>).

error: command 'gcc' failed with exit status 1
----------------------------------------

错误:命令 "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -u -c 'import setuptools, tokenize;file='"'"'/private/ var/folders/qf/kmd2_y0j2p9_10zkd5ctvm880000gn/T/pip-install-i0kg4ysj/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close ();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/qf/kmd2_y0j2p9_10zkd5ctvm880000gn/T/pip -record-lkzzuu55/install-record.txt --single-version-externally-managed --compile" 失败,错误代码 1 在 /private/var/folders/qf/kmd2_y0j2p9_10zkd5ctvm880000gn/T/pip-install-i0kg4ysj/psycopg2/

【问题讨论】:

  • pip3 install psycopg2 工作吗?

标签: python python-3.x psycopg2


【解决方案1】:

成功安装 python 和 pip 后,这个命令应该可以工作: 点安装 psycopg2

【讨论】:

    【解决方案2】:

    您无法安装 psycopg2,因为您设备中的 gcc 编译器已过时且无法安装和运行它,或者它不存在。

    如果您只是运行pip install psycopg2-binary,那么它将在您的开发和测试环境中运行,但不建议在生产环境中使用。

    要安装 psycopg2,请通过运行确保您的设备中安装了 gcc-

    gcc --version gcc where

    如果没有安装,请参考这里的指南安装-

    Installing GCC in Mac

    我希望这会有所帮助。 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-12
      • 1970-01-01
      • 2017-10-13
      • 1970-01-01
      • 2019-08-23
      • 2018-07-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多