簡體   English   中英

無法使用XCode4在OSX 10.6.7上安裝psycopg2

[英]Cannot install psycopg2 on OSX 10.6.7 with XCode4

嘗試在OSX上安裝psycopg2會導致以下結果:

building 'psycopg2._psycopg' extension

creating build/temp.macosx-10.6-universal-2.6

creating build/temp.macosx-10.6-universal-2.6/psycopg

gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090003 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -I. -I/usr/local/Cellar/postgresql/9.0.3/include -I/usr/local/Cellar/postgresql/9.0.3/include/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.6-universal-2.6/psycopg/psycopgmodule.o

/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/darwin/ppc/as) for architecture ppc not installed

Installed assemblers are:

/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64

/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386

psycopg/psycopgmodule.c:1009: fatal error: error writing to -: Broken pipe

compilation terminated.

lipo: can't open input file: /var/folders/zf/zfsYTD29GwSWm+UDcF6VxE+++TM/-Tmp-//ccd8ckcV.out (No such file or directory)

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

有誰知道我該怎么做才能安裝它? 我安裝了Postgres,似乎工作正常。

我已經嘗試了easy_install和pip安裝,但最終都得到了類似的消息。

似乎ARCHFLAGS實際上有問題,所以最后使用:

sudo env ARCHFLAGS =“ - arch i386 -arch x86_64”pip install psycopg2

實際上工作。

問題是OS X 10.6附帶的Python 2.6是為三種支持的體系結構(i386,x86_64和ppc,以便與早期版本的OS X兼容)構建的,而Python的Distutils試圖確保所有C擴展模塊都使用相同的構建arch s作為Python解釋器和庫。 但Xcode 4顯然已經取消了對PPC的支持。 在官方補丁可用之前,您可以:

  • 在運行pyscopg2的setup.py腳本時覆蓋arch(正如Adam指出的那樣,Distutils ARCHFLAGS是這樣做的方法)
  • 回到使用Xcode 3(或嘗試一些不受支持的黑客在Xcode 4旁邊安裝Xcode 3)
  • 嘗試使用不同的Python。 例如,對於Python 2.7,python.org 在這里提供了i386 / x86_64 Python的安裝程序
  • 或者您可以使用第三方軟件包管理器(如MacPorts)構建和安裝所需的一切。

     sudo port install py27-psycopg2 # installs Python2.7, portgresql, and pysycopg2 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM