我无法在 Mac 上使用 Python3 安装 Psycopg2.我已经安装了 Python3 和 pip3 [英] I can't install Psycopg2 with Python3 on Mac. I've installed Python3 and pip3

查看:69
本文介绍了我无法在 Mac 上使用 Python3 安装 Psycopg2.我已经安装了 Python3 和 pip3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've tried to type this command: pip3 install --user psycopg2 psycopg2-binary

Bash 答案:错误:运行安装

Bash answers: ERROR: running install

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

ERROR: Command "/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" failed with error code 1 in /private/var/folders/qf/kmd2_y0j2p9_10zkd5ctvm880000gn/T/pip-install-i0kg4ysj/psycopg2/

推荐答案

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

You're not being able to install psycopg2 as the gcc compiler in your device is either outdated and not compatible to install and run it, or it does not exist.

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

if you just run pip install psycopg2-binary, then it will work on your development and testing environment, however it is not recommended for production.

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

To install psycopg2, make sure that you have gcc installed in your device by running-

gcc --versiongcc where

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

If it is not installed, then install it by referring to the guide here-

在 Mac 上安装 GCC

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

I hope this helps. :)

这篇关于我无法在 Mac 上使用 Python3 安装 Psycopg2.我已经安装了 Python3 和 pip3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆