【问题标题】:I'm trying to install psycopg2 onto Mac OS 10.6.3; it claims it can't find "stdarg.h" but I can see it's there; what should I do?我正在尝试将 psycopg2 安装到 Mac OS 10.6.3 上;它声称它找不到“stdarg.h”,但我可以看到它在那里;我该怎么办?
【发布时间】:2011-03-03 22:54:53
【问题描述】:

我正在拼命尝试成功安装 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 

【问题讨论】:

    标签: python macos postgresql osx-snow-leopard psycopg2


    【解决方案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(以及一些其他技巧以使其识别 gcc-4.2)。

    【讨论】:

      【解决方案2】:

      以下对我有用:

      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 和朋友是一项可以很快获得回报的前期投资,尤其是在处理具有大量依赖项的项目时。

      【讨论】:

        【解决方案3】:

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

        sudo port install py26-psycopg2
        

        【讨论】:

        • @cojadate 这取决于您当前使用的 Python 版本。如果您使用 python2.6 运行,则 py26-psycopg2 是正确的选择。 psycopg2 肯定已安装,但我猜它不在您的 Python 路径中。
        • @cojadate 如果您使用 MacPorts 安装了 psycopg2,则需要确保您使用的是 Python 的端口版本,而不是 OSX 附带的版本。确保/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin/ 或类似名称在PATH 中位于/usr/bin 或what-have-you 之前。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-02-14
        • 2013-10-03
        • 1970-01-01
        • 2023-03-03
        相关资源
        最近更新 更多