简体   繁体   中英

how to install psycopg2 on OSX 10.7

I followed the following procedure:

1) $ sudo pip install psycopg2

This gave me the following error

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) Then I searched on web for installing llvm-gcc-4.2 and from this http://developer.apple.com/library/mac/#releasenotes/DeveloperTools/RN-llvm-gcc/_index.html got to know that I need to install Xcode

Also from this psycopg2 installation problem on OSX Lion I came to know that I can install psycopg2 via macports but then from this http://www.macports.org/install.php came to know that I need xcode again.

3) Finally I tried to install Xcode from apple store, it downloaded 1.6 gb file and after that says that it is now installed on my system. Here is the screenshot of the same

![macports installed image][1]

4) And then I tried to install macports via the dmg file available at http://www.macports.org/install.php but it says that xcode not yet installed on my system. Here is the screenshot of the same. ![when trying to install macport, xcode not installed message appears][2]

There is an additional detail missing here. In Xcode 4.3 and higher you need to install the command-line tools as a separate step. You need to do this in order for the script to initiate the call to the command line version of llvm-gcc-4.2

Go to Xcode > Preferences > Downloads > Command Line Tools Install.

The problem most likely is that you only downloaded the Xcode INSTALLER from the App Store. You now need to run the installer to install Xcode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM