David (dblume) wrote,
David
dblume

How to install PyGreSQL (Python's PostgreSQL module)

Installing PyGreSQL isn't trivial, especially on Dell computers.  Here's a recipe that worked for me and Python 2.5:

  1. Download and install postgresql-8.3.5-2-windows.exe  (You shouldn't need the whole install.)
  2. Add C:\Program Files\PostgreSQL\8.3\lib to your PATH for libpq.dll.
  3. Add C:\Program Files\PostgreSQL\8.3\bin to your PATH for ssleay32.dll.
  4. Hide System32's copy of LIBEAY32.dll  (If you're on a DELL, and that one is far smaller and older than the others.)
  5. Download and install PyGreSQL-4.0.win32-py2.5.exe
And here's some explanation with accompanying error text so that people searching for a solution to this problem can find it.  Here's my experience:

Downloaded PyGreSQL first, before realizing it had dependencies to a postgresql install.  Got some nebulous ImportErrors when I tried to "import pg".

from _pg import *
ImportError: DLL load failed: The specified module could not be found.
Great.  What module?  Searching the web, I discovered I needed to install postgresql.  So I did, but I still got the error, even after updating the system's PATH variable.  (Note, sys.path and os.environ("PATH") are two different things.)  Eventually I discovered this great tip:

Try doing the failing import from the Python command line.  (Start->Python 2.5->Python (command line)).  Doing that will actually display a modal dialog that says exactly which dll could not be loaded.  Yay!

Finally, I got the LIBEAY32.dll error mentioned above, the exact text of which follows:

The ordinal 2821 could not be located in the dynamic link library LIBEAY32.dll
and once I hid the old LIBEAY32.dll, I got pg linking with the correct libraries, I was good to go.  Hope this helps somebody.

Tags: programming, python, solved
Subscribe

  • Progress on my Google+ and LJ backups

    Since Google is going to shut down Google+, I decided it was time to really make a home for my LiveJournal backup and my Google+ backup. Working…

  • Getting Shit Done

    I came across an old LifeHacker article Get Shit Done Blocks Distracting Web Sites So You Can Do As the Name Instructs, that mentions a productivity…

  • Fifth Grade Homework - Nine digit pandigital prime number

    Yesterday my daughter in the fifth grade got the following homework assignment "arrange the digits one through nine into a nine-digit prime number."…

  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 5 comments