0

Short Description
I am having a number of issues trying to connect a Django app (currently setup as SQLite3) to a newly created PostgreSQL on my Ubuntu Server.

The Question(s)
Can anyone share their success in doing this? Is there a good step-by-step tutorial on doing this? Or at least useful pointers on how to debug this?

Steps So Far (Background information)
1) I have installed PostgreSQL on my Ubuntu Server following this tutorial. Note that this produced Zero errors.
2) I configured my Django settings.py as seen below

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql', 
    'NAME': 'mytestdb',                   
    'USER': 'mux_user',                    
    'PASSWORD': 'mux',                  
    'HOST': '192.168.1.111',                      
    'PORT': '',                  
    }
}

3) Ran Django's 'syncdb'. This generated the following error.

django.core.exceptions.ImproperlyConfigured: Error loading psycopg module: No module named psycopg

4) Attempted to install psycopg with PIP, easy_install, and with the setup.py. All had the same failure of not being able to find the pg_config.

5) Google told me that I needed to install libpq-dev and python-dev in-order to compile the psycopg package. This is where I have lost most of my confidence in understanding what I am doing. I understand that these 2 packages are to allow me to compile python source, but is it really necessary to do this?

System Information
Client:
OS: OS X Snow Leopard-10.6.6
Django: Version 1.2.5
Python: 2.7 (running virtualenv)

Soon to be client
OS: Windows XP / 7
Running an bundled executable of the python environment above

Server:
OS: Ubuntu 10.10 (server, no gui)
PostgreSQL: 8.4 (that's what apt-get install downloaded)

Update
I did find in the documentation where it talks about needing to install psycopg. I suppose the question moves from do I really need this, to what is the best way to install psycopg on my clients.

Update 5-13-2011: 9:20AM
After speaking with a colleague, I believe this SO question addresses most of my issues

3 Answers 3

1

I'm no Python guy but you do need the PostgreSQL libraries installed as the Python interface to PostgreSQL (psycopg) is just a Python layer on top of the PostgreSQL C libraries. So, no PostgreSQL development libraries means there's nothing to wrap in Python and no way to talk to PostgreSQL from Python.

Sign up to request clarification or add additional context in comments.

5 Comments

This is exactly why I started to install psycopg. However, I do not know if this is required when using Django. Judging by my errors, I would say yes, but I could not find anywhere in the Django documentation about needing this module. Thanks for the quick answer!
@Adam: I don't think Django itself needs psycopg or any of its supporting libraries but your application needs to talk to PostgreSQL so your application needs psycopg and friends.
@Adam: I think brew install postgresql should get you everything you need if you're using Homebrew. That'll give you the server as well as the libraries but that shouldn't be a big deal as the server won't run unless you ask it to.
@mu: That's exactly what I have done. However, now I am having troubling installing Postgres with homebrew :| I just can't win.
@mu: I will look into Cinderalla. Thanks for the tip. Regarding the "having trouble installing PostreSQL", I would rather start up a new question once I have more intelligent things to say than 'HELP!' :)
0

You need to put your pg_config into your path, first locate this file on your machine, then run something similar to:

    export PATH=$PATH:/opt/local/lib/postgresql90/bin
    pip install psycopg2

If you do not have postgres installed on your client machine, then you should be able to install with macports:

    sudo port install postgresql90

1 Comment

As I pointed out in my question, I do not have pg_config on my machine. I am not at a point where I can look this up, so do you know if I can install what I need with homebrew?
0

The issues I ran into were centered around using a 32bit install of Python (required by wxPython 2.8 on Snow Leopard). Please see my answer on this SO Question.

@mu is too short: Thanks for the help.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.