About Me

2009年9月18日星期五

Upgrading to Apple 64-bit OS Snow Leopard, I found that have to re-configure my development environment. After bunch of google and try, finally I make postgresql, psycopg2 and (apple) python readline work in 64-bit. The postgresql is 8.3 from MacPort, psycopg2 installed from source and I'm using python ship with system.

First follows migration guideline to migrate macports (included postgresql 8.3). Then I found that psycopg2 can not be imported.

Symbol not found: _PQbackendPID

I found a solution from kreeger's blog that run system python in 32-bit mode, it works. However later I meet readline issue that it can not work with 32-bit python.

defaults write com.apple.versioner.python Prefer-32-Bit -bool yes

I can install readline successfully follows Zachary Voase’s blog, he provided a patched egg just works (I also try steps by steps, the same). Then I installed IPython, found readline can not recognize by the IPython, since import readline is failed. After switch back to 64-bit python, it works again. So I have to find a way to either make psycopg2 work with 64-bit python or make readline work with 32-bit python, I prefer the first one. So I got the 64-bit python back.

defaults write com.apple.versioner.python Prefer-32-Bit -bool no

Lucky enough by tracking Nick Takayama 's twitter, Here's a way to make psycopg2 work with 64-bit python.

If you run 'otool -L /Library/Python/2.6/site-packages/psycopg2/_psycopg.so' make sure that libpq is not listed in the output. Then try import it. Boom works for me.

Other solution: I also saw a solution to make an universal postgresql8x for x86_64 and i386, then manually build psycopg2. However I can not macport it successfully, I failed on building libxslt +universal. You can try it fromMads Sülau Jørgensen's blog.

Upgrading to Apple 64-bit OS Snow Leopard, I found that have to re-configure my development environment. After bunch of google and try, finally I make postgresql, psycopg2 and (apple) python readline work in 64-bit. The postgresql is 8.3 from MacPort, psycopg2 installed from source and I'm using python ship with system.

First follows migration guideline to migrate macports (included postgresql 8.3). Then I found that psycopg2 can not be imported.

Symbol not found: _PQbackendPID

I found a solution from kreeger's blog that run system python in 32-bit mode, it works. However later I meet readline issue that it can not work with 32-bit python.

defaults write com.apple.versioner.python Prefer-32-Bit -bool yes

I can install readline successfully follows Zachary Voase’s blog, he provided a patched egg just works (I also try steps by steps, the same). Then I installed IPython, found readline can not recognize by the IPython, since import readline is failed. After switch back to 64-bit python, it works again. So I have to find a way to either make psycopg2 work with 64-bit python or make readline work with 32-bit python, I prefer the first one. So I got the 64-bit python back.

defaults write com.apple.versioner.python Prefer-32-Bit -bool no

Lucky enough by tracking Nick Takayama 's twitter, Here's a way to make psycopg2 work with 64-bit python.

If you run 'otool -L /Library/Python/2.6/site-packages/psycopg2/_psycopg.so' make sure that libpq is not listed in the output. Then try import it. Boom works for me.

Other solution: I also saw a solution to make an universal postgresql8x for x86_64 and i386, then manually build psycopg2. However I can not macport it successfully, I failed on building libxslt +universal. You can try it fromMads Sülau Jørgensen's blog.