ORIGINAL MESSAGE (now outdated):
After running python setup.py install I get the following:
Warning: Unable to find 'pg_config' filebuilding 'psycopg2._psycopg' extension
gcc-4.0 -arch ppc -arch i386 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 - DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.2.1 (dt dec ext pq3)" -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -I. -c psycopg/psycopgmodule.c -o build/temp.macosx-10.3-fat-2.6/psycopg/psycopgmodule.o
unable to execute gcc-4.0: No such file or directory
error: command 'gcc-4.0' failed with exit status 1
There's probably something screamingly obvious there to anyone who knows the first thing about back-end web programming, but unfortunately it's all gobbledegook to me. The psycopg2 documentation was not helpful.
UPDATE early 12 June: After updating all my software, the error message has changed.
Now, when I run "python setup.py install" I get the following:
Warning: Unable to find 'pg_config' filebuilding 'psycopg2._psycopg' extension
gcc-4.0 -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.2.1 (dt dec ext pq3)" -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -I. -c psycopg/psycopgmodule.c -o build/temp.macosx-10.3-fat-2.6/psycopg/psycopgmodule.o
followed by a very long list of other error messages.
It may or may not be relevant that when I put "gcc-4.0" into Terminal, it comes back with:
i686-apple-darwin10-gcc-4.0.1: no input files
UPDATE 12:41 GMT 12 June: I thought the macports installation had worked, but when I tried running a site it ended with the following error:
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named psycopg2
So I guess that means that psycopg2 hadn't installed properly after all. So I'm back to square one.
Install PostgreSQL for Mac - http://www.postgresql.org/download/macosx
set the path to the new PostgreSQL location for psycopg2 install:
I think you're making it harder than it has to be. Rather than running setup.py directly, I suggest letting MacPorts do it for you:
sudo port install py26-psycopg2
I am sure that we would all hate to overlook the "screamingly obvious", so perhaps it is worth a check before going and installing a new compiler. In this case it could be that PostgreSQL is not installed on the person's Mac. Hence psycopg2 cannot find the 'pg_config' program that comes with newer versions of that database, causing the warning-message "Unable to find 'pg_config'" to be emitted.
So, before fiddling with a new compiler or any other part of the Developer toolchain, first check and see if you have PostgreSQL installed. If you do then find the 'pg_config' program, and set that path in the 'setup.cfg' file in the psycopg distribution. Then run 'python setup.py install' and see if you get the same error messages. Hopefully, it just starts "compiling"; but if it doesn't then you would be justified in executing the more difficult procedures described above.
If you've installed postgres from Enterprise DB you'll prob just want to
or similar - depending on the version you have.
If it complains about
then it doesn't like your newer gcc - you can overwrite your gcc to force it to use gcc4.0 by doing:
and then re-running your easy_install again.
(See edits below for your updated question)
You don't have the "gcc4.0" compiler executable on your machine, or the right version, or installed in a location that python can't find/use. XCode/Developer Tools (which include GCC) should be on your original OSX installation DVDs.
Since you're humble enough to call yourself a newbie, here's a nugget of wisdom... Resolving this error really has nothing to do with back-end web development, as it is your local development environment (your machine and all the software as it is configured and installed) that is the problem. The best tip I have for deciphering gobbledegook like this is to start Googling keywords for things you've never heard of before. If I were in your shoes, this error message screams to me to "go find out what the heck is gcc4.0. Then, when I know what it is and what it does, and why python needs it, then I figure out why python can't find it on my computer, and then I do something about it." The satisfaction of resolving these kinds of issues doesn't happen for everyone, though, that's for certain.
The answer to all those questions is this: psycopg2 is a python extension that is written in the C language. A lot of extensions for python are written in C, not python, since C is much more optimized than python will ever be. That's what the python interpreter itself is written in, actually. C language code has to be compiled before it is usable (unlike python code, which is interpreted) and in this case, the compiler you need is gcc4.0. Now, perhaps if you were using Windows or Linux, the compiled version of psycopg2 might have been available already, and you wouldn't need GCC installed, as you wouldn't have to compile it to use it (it would be compiled already for you). But, it seems you'll have to compile it yourself on OS X, and to do that, you need the program "gcc4.0" to be available in the system PATH so that the setup script you're trying to run can find and use it. On OS X, you can get it from your original installation DVDs that ship with your computer. Pop them in the drive and find the Developer Tools installation program. Once you've got that installed, you should then be able to check if the GCC 4.0 compiler is installed by trying to run the command "gcc4.0" in any console window and see if it installed and in in your path.
Edit for your update
It looks like you now have a good installation of the GCC 4.0 compiler! Good work. When you see this:
That output is compiler telling you its exact version, and then telling you that you gave it no parameters, so, it won't do anything for you. Which is okay, since your psycopg2 setup script is going to call it, not you directly.
Next up, it looks like psycopg2 expects that you should have PostgreSQL server development libraries installed as well. Since I see you're now using MacPorts, you should be able to install these libraries easily with this command:
That should get you your missing
pg_config
executable that the setup is looking for.Keep us updated on your progress!