如何在OSX 10.7上安装psycopg2

4
我按照以下步骤进行了操作:
1)$ sudo pip install psycopg2 这给我带来了以下错误。
Downloading/unpacking psycopg2
  Running setup.py egg_info for package psycopg2

    no previously-included directories found matching 'doc/src/_build'
Installing collected packages: psycopg2
  Running setup.py install for psycopg2
    building 'psycopg2._psycopg' extension
    llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.3 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090004 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/include -I/usr/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.7-intel-2.7/psycopg/psycopgmodule.o
    unable to execute llvm-gcc-4.2: No such file or directory
    error: command 'llvm-gcc-4.2' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/Users/boltellinfomedia/mukul/mukul/build/psycopg2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-8NaS72-record/install-record.txt:
    running install

running build

running build_py

running build_ext

building 'psycopg2._psycopg' extension

llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.3 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090004 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/include -I/usr/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.7-intel-2.7/psycopg/psycopgmodule.o

unable to execute llvm-gcc-4.2: No such file or directory

error: command 'llvm-gcc-4.2' failed with exit status 1

----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/Users/boltellinfomedia/mukul/mukul/build/psycopg2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-8NaS72-record/install-record.txt failed with error code 1
Storing complete log in /Users/boltellinfomedia/.pip/pip.log

2) 接着我在网上搜索了安装llvm-gcc-4.2,从这个链接得知需要安装Xcode

又从这个链接中得知可以通过macports安装psycopg2但是从这个链接中得知我仍然需要Xcode。

3) 最后我试着从苹果商店安装Xcode,它下载了1.6 GB的文件并且显示已经安装在我的系统中。下面是截图:

![macports installed image][1]

4) 然后我试着通过可从链接获得的dmg文件安装macports,但是提示我尚未安装Xcode。下面是截图:![when trying to install macport, xcode not installed message appears][2]


我无法添加图片,因为我没有10个声望点。一旦我获得它们,我会添加这些图片。 - mukul
2个回答

3

这里还有一个额外的细节需要补充说明。在 Xcode 4.3 及以上版本中,您需要单独安装命令行工具。您需要执行此操作,以便脚本能够调用 llvm-gcc-4.2 的命令行版本。

前往 Xcode > 首选项 > 下载 > 安装命令行工具。


1
谢谢。这帮助我解决了在升级到Mountain Lion后重新安装Python 2.7时出现的“无法执行clang”的问题。 - Tom
我已经起床2小时了,编辑我的bash并尝试各种技巧。这解决了它。 - Gazzini

2
问题很可能是您只从App Store下载了Xcode安装程序。现在需要运行安装程序来安装Xcode。

感谢您抽出时间。我无法附加图像,否则我会向您展示苹果商店显示Xcode已安装的情况。没有重新安装或卸载的链接,我该如何调试此问题。 - mukul
以下是图片链接:http://imageshack.us/photo/my-images/213/screenshot20111219at443.png/ - mukul
正如你所说,我发现安装程序文件只是被下载而没有被安装。最终我找到了安装它的链接。虽然这很奇怪,即使应用程序没有被安装,苹果商店也显示它已经安装了。最终在你的帮助下一切都得到了解决。 - mukul

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接