安装psycopg2完全失败。巨大的错误消息(例如错误:命令'gcc'失败,退出状态为1)

2024-10-03 23:31:16 发布

您现在位置:Python中文网/ 问答频道 /正文

在mac上安装psycopg2时出现问题。我尝试了几种方法,比如用pip安装它,还有自制程序。我也下载了所有的依赖项,但仍然无法安装。在

我收到以下错误消息,看起来很可怕:

Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/1c/nhs40gy513143dfqyblmt3r80000gn/T/pip-install-rxlPem/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/1c/nhs40gy513143dfqyblmt3r80000gn/T/pip-record-93LksX/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/1c/nhs40gy513143dfqyblmt3r80000gn/T/pip-install-rxlPem/psycopg2/

可能是什么问题?在

编辑:可以找到完整的错误here,这似乎是最相关的部分:

^{pr2}$

Tags: installpipvar错误codeopenprivaterecord
2条回答

psycopg2has some install dependencies that might be giving you trouble。在本例中,安装过程似乎找不到^{},它是C标准库的一部分。Installing the Xcode Command Line Tools可能会有帮助。在

但如果您不想为此烦恼,请尝试安装^{}

You can also obtain a stand-alone package, not requiring a compiler or external libraries, by installing the psycopg2-binary package from PyPI:

$ pip install psycopg2-binary

The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources.

对于任何一个寻求解决方案或未来参考的人来说

我在Mojave上安装psycopg2时遇到了这个问题,接下来,我可以找到指向psycopg2githubissue的链接。它的解决方案是安装缺少的库头,使用

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

这可能是莫哈韦的问题,enter link description here

相关问题 更多 >