当前位置: 首页 > 知识库问答 >
问题:

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

沈栋
2023-03-14
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/

会有什么问题?

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

clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.sdk' [-Wmissing-sysroot]
In file included from psycopg/psycopgmodule.c:27:
In file included from ./psycopg/psycopg.h:34:
/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m/Python.h:25:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.

共有1个答案

呼延烈
2023-03-14

psycopg2有一些安装依赖项可能会给您带来麻烦。在本例中,安装过程似乎找不到stdio.h,这是C标准库的一部分。安装Xcode命令行工具可能会有所帮助。

但如果您不想为此费心,请尝试安装psycopg2-binary:

您还可以通过从PYPI安装psycopg2-binary包来获得独立的包,而不需要编译器或外部库:

$ pip install psycopg2-binary
 类似资料: