我拼命想成功安装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
答案 0 :(得分:3)
答案 1 :(得分:3)
以下适用于我:
$ mkvirtualenv --no-site-packages --distribute psycopg2_test
$ cd $VIRTUAL_ENV
$ pip install psycopg2
以上命令使用:
我通过以下方式引导pip
:
wget http://python-distribute.org/distribute_setup.py
python distribute_setup.py
easy_install pip
更新:我意识到这似乎有很多牦牛剃须,但学习如何使用virtualenv
和朋友是一个前期投资,很快得到回报,特别是在处理有很多项目时的依赖关系。
答案 2 :(得分: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)。