Today I’ve had to install psycopg on my MacBook Pro running Mac OS X 10.6.8 (10K549) and I had some troubles doing that, so I’ll post this here just for the records.
To install PostgreSQL, i used the .dmg provided by postgresql web itself, as I’m not a big fan of fink or macports. And I downloaded psycopg from the project web. I’m not a big fan of Fink or MacPorts, so I didn’t use any of them to get any software, actually.
My first attempt was to install psycopg as usual, typing ‘$python setup.py install’, but I get this error:
1 2 3 4 |
<em>Please add the directory containing pg_config to the PATH</em> <em>or specify the full executable path with the option:</em> <em> python setup.py build_ext --pg-config /path/to/pg_config build ...</em> <em>or with the pg_config option in 'setup.cfg'.</em> |
That one was easy. I just added the location of pg_config at the end of the command. It looked like this: ‘$PATH=$PATH:/Library/PostgreSQL/9.1/bin python setup.py install’. Note that this is the path for a typical dmg installation of PostgreSQL on a Mac. It may differ to the one on your system.
And this is when things got complicated. The next error the system spit looked like this:
1 2 3 4 5 6 7 8 |
<em>Running psycopg2-2.4.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-LKNkhA/psycopg2-2.4.2/egg-dist-tmp-PbhT1X</em> <em>no previously-included directories found matching 'doc/src/_build'</em> <em>/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</em> <em>Installed assemblers are:</em> <em>/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64</em> <em>/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386</em> <em>psycopg/psycopgmodule.c:1035: fatal error: error writing to -: Broken pipe</em> <em>compilation terminated.</em> |
I then swith to easy_install, which is probably the easiest way to get python modules onto your system. Then, I typed: ‘$PATH=$PATH:/Library/PostgreSQL/9.1/bin/ sudo easy_install psycopg2’, but the same error appeared.
I also used pip, just in case ‘PATH=$PATH:/Library/PostgreSQL/9.1/bin pip install psycopg2’, but it resulted in the same error, again.
Finally, I assumed this should be something related to the architecture (well… that word appeared a couple of times in the error message… not a so-educated guess). I googled for a while and I found the answer in this post in StackOverflow.
Adding that env directive to the command, make it look like this: ‘$PATH=$PATH:/Library/PostgreSQL/9.1/bin sudo env ARCHFLAGS=”-arch i386 -arch x86_64″ pip install psycopg2’ and tada! It worked
1 2 |
<em>Successfully installed psycopg2</em> <em>Cleaning up...</em> |
I think this is something related to the development environment. Probably somehow related to XCode and iPhone development 🙁
Hope this helps.
I found the same thing, that Mac Ports and Fink were more trouble than they were worth and despite the warnings on the Psycopg website it was much easier to use easy install (especially when you’d done the hard work).
I found the same thing, that Mac Ports and Fink were more trouble than they were worth and diptese the warnings on the Psycopg website it was much easier to use easy install (especially when you’d done the hard work).
I need to say thank you so much for that work you have made in writing this posting. I am hoping the same perfect job from you down the road too.
I
ve heard postgreSQL is better for transaction processing than MySQL with InnoDB?
Although I dont know why, how or by how much?
I`d appreciate a simple English analysis.
Hi,
Thanks for posting this. Should the command to add to the path not have a leading $? Should it be this:
PATH=$PATH:/Library/PostgreSQL/9.1/
Thanks,
Chuck
OMG!!! It works. THANK YOU.
Hi.. I’ve been fighting this with and just came aoscrs your post. i ran the command like you have it verbatim and get the follwoing error. Any ideas what I may be doing wrong?/usr/local/zend/apache2/build-1/libtool silent mode=compile gcc -prefer-pic -O2 -pipe -g -fno-common -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp -I/usr/local/pcre-7.8/include -I/usr/local/zend/apache2/include -I/usr/local/zend/apache2/include/apr-1 -I/usr/local/zend/apache2/include/apr-1 ”-arch -c -o mod_xsendfile.lo mod_xsendfile.c && touch mod_xsendfile.sloi686-apple-darwin10-gcc-4.2.1: ”-arch: No such file or directoryapxs:Error: Command failed with rc=65536
Pingback: Error: No module named psycopg2.extensions - ExceptionsHub
Hi,
What about spsycop2 instal for Windows?
thank you for back