Postgres, Django and that Damn Clang Error

I'm migrating to PostGres for one of my Django projects. (From MySQL) I'm writing this more as a note for myself, but if someone else finds it useful, go for it. If you've done this on a Mac, you may have seen the following errors.

</p>

Error: pg_config executable not found.


</p>

If you've found that error, then you may not have Postgres installed. If you do have Postgres installed then make sure the installs bin directory is in your path. If you don't have Postgress installed, the easiest way is Postgres.app. After installing Postgres drop to a terminal and add a new value to your PATH.

</p>

export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin
pip install psycopg2

</p>

Don't feel discouraged when this fails again. Because it probably will. The message is extremely helpful if you've got your Ph.D.

</p>

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1


</p>

It may not be downgraded in the future, but today is not tomorrow. So lets hack this bad boy.

</p>

Things you need:

</p>

  1. If you don't have it already, download Xcode and install it.

</p>

1a. Drop to a terminal and install the command line tools with

</p>

xcode-select --install

</p>

  1. If you already had Xcode installed and it's version 4.2 or earlier, skip ahead to step X. If you downloaded Xcode in step 2, you'll need to install some additional compiler tools that were removed from Xcode. The best way is to use Homebrew. (You are using Homebrew RIGHT?)

    </p>

    brew install apple-gcc42

  2. </p>
  3. Once that's complete. If this works, you're done. If not (and it probably won't) move on to step4.

    </p>

    pip install psycopg2

  4. </p>
  5. Set an environment flag to skip the BS compiler flags being used.

    </p>

    export ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future
    pip install psycopg2


</p>

With any luck, that will result in a successful install.

</p>

comments powered by Disqus