macosx

Installing psycopg2 on Mac 10.6.4 Snow Leopard

Setting up Django for use with Postgres 8.3. Django uses psycopg2 (or psycopg depending on what you choose). To the best of my knowledge psycopg2 v2.2.2 is the most stable version of the code.

easy_install "psycopg2=2.2.2"

Then edit your settings.py file for Django.

DATABASE_ENGINE = ‘postgresql_psycopg2’

Psycopg2 Error

The easy_install for psycopg2 didn’t work immediately because easy_install could not find pg_config and caused compile process failed. To fix the problem I needed my environment to have access to Postgres 8.3 pg_config. The default MacPorts install of Postgres 8.3 drops pg_config and other key files into /opt/local/lib/postgresql83/bin/ .

To allow your easy_install environment to see pg_config, simply symbolically link it to your ~/bin directory. It does not have to be ~/bin. It could be any directory on your environment path. Just pick something easy.

# symbolic link from MacPorts install of postgres to a path on my home dir.
ln -s /opt/local/lib/postgresql83/bin/pg_config ~/bin/pg_config

I edited my .bash_profile so that the files in ~/bin is always on my environment path.

# set PATH so it includes user’s private bin if it exists
if [ -d ~/bin ] ; then
    PATH=~/bin:"${PATH}"
fi
 
if [ -f /opt/local/etc/bash_completion ]; then
    . /opt/local/etc/bash_completion
fi

Change Windows type line endings to Mac

To convert files from windows (or DOS) type line endings to UNIX or Mac flavor use “flip”

Convert DOS or Windows line endings to Unix or Mac

flip -d <filename>

Convert Unix line endings to Windows

flip -u <filename>

To install flip on Mac:

sudo port install flip

To install flip on Ubuntu Linux

sudo apt-get install flip

How do you know your line endings are DOS or Windows flavor? Open your text file with a plain text editor. If you see a “^M” at the end of every line then your line endings are DOS/Windows.

From the flip Usage instructions

Usage: flip [-t|-u|-d|-m] filename[s]
   Converts ASCII files between Unix, MS-DOS/Windows, or Macintosh newline formats
 
   Options: 
      -u  =  convert file(s) to Unix newline format (newline)
      -d  =  convert file(s) to MS-DOS/Windows newline format (linefeed + newline)
      -m  =  convert file(s) to Macintosh newline format (linefeed)
      -t  =  display current file type, no file modifications

Sanitize, tidy, or cleanup Word HTML using word unmunger

Word Un-munger python script will convert and clean crappy Word HTML to decent HTML.

Automator Script will make it easier to convert clean the Word HTML of several pages in a batch job.

Syndicate content