python - 如何在 OSX 10.7 上安装 psycopg2

标签 python macos postgresql psycopg2

我遵循了以下程序:

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 并从此 http://developer.apple.com/library/mac/#releasenotes/DeveloperTools/RN-llvm-gcc/_index.html 知道我需要安装 Xcode

也来自这个psycopg2 installation problem on OSX Lion我开始知道我可以通过 macports 安装 psycopg2,然后从这个 http://www.macports.org/install.php才知道我又需要 xcode。

3) 最后我尝试从苹果商店安装 Xcode,它下载了 1.6 GB 的文件,然后说它现在已经安装在我的系统上了。这是相同的屏幕截图

![macports 安装图像][1]

4) 然后我尝试通过 http://www.macports.org/install.php 提供的 dmg 文件安装 macports但它说 xcode 尚未安装在我的系统上。这是相同的屏幕截图。 ![尝试安装 macport 时,出现 xcode not installed 消息][2]

最佳答案

这里缺少一个额外的细节。在 Xcode 4.3 及更高版本中,您需要单独安装命令行工具。您需要执行此操作,以便脚本启动对 llvm-gcc-4.2 命令行版本的调用

转到 Xcode > 首选项 > 下载 > 命令行工具安装。

关于python - 如何在 OSX 10.7 上安装 psycopg2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8555754/

相关文章:

python - tensorflow : "trying to mutate a frozen object",巴泽尔

SQL 查询不工作,不返回任何内容

sql - 在 SQL 中编写自己的函数的任何可能性(用户定义的函数 SQL)

java - 如何使用 JDBI 将 2d 数组从 PostgreSQL DB 转换为 java 2d 数组?

python - PyOpenGL:渲染......好吧......任何真的

python - 如何在jupyter notebook上跟踪python的执行进度?

python - pytesseract : good OCR or good Lines - never both

macos - 如何在另一个 bash 脚本中增加一个全局变量

python异步套接字编程

java - 了解不同版本的 Java 在 Mac OS 上的共存