Symbol not found: _PQbackendPID with Django project
Question: Running on MAC os 10.6.8 with postgresSQL installed, as well django - using
python2.7 Also installed psycopg2 and dj-database-url using pip in my virtual
env And added these two lines to my setting.py:

    
    
    import dj_database_url
    DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
    

Based on instructions for Heroku in:
<https://devcenter.heroku.com/articles/django#database_settings> When running:

    
    
    python manage.py runserver
    

I am getting this error:

    
    
    ImportError: dlopen(/Users.... venv/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: _PQbackendPID
    Referenced from: /Users.... venv/lib/python2.7/site-packages/psycopg2/_psycopg.so
    Expected in: dynamic lookup
    

I kept searching for hours and tried all kind of thing including the advice
on: [Mac OS X Lion Psycopg2: Symbol not found:
_PQbackendPID](http://stackoverflow.com/questions/6999105/mac-os-x-lion-
psycopg2-symbol-not-found-pqbackendpid) to no avail.

Wonder if anyone had such an issue and had any luck.


Answer: I had the same problem. Instead of installing the dependencies as Heroku
suggests using

    
    
    pip install Django psycopg2 dj-database-url
    

clone whatever repo you're hoping to run in venv, keeping its original
settings.py. Then:

    
    
    source venv/bin/activate
    

to activate the new environment, `cd` into your new repo, and `python
manage.py runserver`. Should be set.

Alternatively, you could remake PostGreSQL, and run again, but that's a bit
more of a task - it would work for psycopg2, though. As far as I can tell that
issue comes from using an 64 or i386 build when you should be using a 32 build
- but I'm not sure about this, and the above solution works well to solve the
problem and use venv for what you're actually going to be using it for, most
likely.

