5

我拼命尝试成功安装 psycopg2,但一直遇到错误。最新的似乎不是找到“stdarg.h”(参见下面的代码)。但是我可以亲眼看到一个名为 stdarg.h 的文件存在于 /Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h (它声称找不到任何东西)所以我已经不知道该怎么办。

我正在运行 Mac OS 10.6.3,在过去的几天里,我确保我拥有所有最新的 OS 开发人员工具。

如果有什么不同的话,我有 Python 2.6.2 和 PostgreSQL 8.4。

python setup.py install    
running install
running build
running build_py
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.macosx-10.3-fat-2.6
creating build/temp.macosx-10.3-fat-2.6/psycopg
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.2.1 (dt dec ext pq3)" -DPG_VERSION_HEX=0x080404 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -I. -I/opt/local/include/postgresql84 -I/opt/local/include/postgresql84/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.3-fat-2.6/psycopg/psycopgmodule.o
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
             from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
             from psycopg/psycopgmodule.c:27:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
             from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
             from psycopg/psycopgmodule.c:27:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
lipo: can't figure out the architecture type of: /var/folders/MQ/MQ-tWOWWG+izzuZCrAJpzk+++TI/-Tmp-//ccakFhRS.out
error: command 'gcc' failed with exit status 
4

3 回答 3

3

我不知道您的具体问题,但我建议您使用macports安装它。
安装psycopg2很简单:

sudo port install py26-psycopg2
于 2010-06-15T12:01:35.563 回答
3

以下对我有用:

  1. $ mkvirtualenv --no-site-packages --distribute psycopg2_test
  2. $ cd $VIRTUAL_ENV
  3. $ pip install psycopg2

笔记

  • 我通过MacPorts安装了我的基础 Python 。
  • 上述命令使用:

  • pip我通过以下方式进行引导:

    1. wget http://python-distribute.org/distribute_setup.py
    2. python distribute_setup.py
    3. easy_install pip

更新:我意识到这似乎是很多牦牛剃须,但学习如何使用virtualenv和朋友是一项前期投资,很快就会得到回报,尤其是在处理具有大量依赖项的项目时。

于 2010-06-15T12:03:28.163 回答
1

我实际上有一个非常相似的问题(OSX Lion,Python 2.7 除外)Can't install psycopg2 in virtualenv "error: stdarg.h: No such file or directory"

我最终使用了这个解决方案:https ://stackoverflow.com/a/8834568/396327

基本上,从头开始卸载/重新安装 XCode(以及更多的 hack 以使其识别 gcc-4.2)。

于 2012-04-27T03:14:39.243 回答