1

Trying to runserver with db['ENGINE'] = 'django.db.backends.psycopg2' I got :

[...]
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/psycopg2/__init__.py", line 67, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
File "/usr/local/lib/python2.6/dist-packages/psycopg2-2.4.4-py2.6-linux-x86_64.egg/psycopg2/__init__.py", line 67, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: /usr/local/lib/python2.6/dist-packages/psycopg2-2.4.4-py2.6-linux-x86_64.egg/psycopg2/_psycopg.so: undefined symbol: Py_InitModule4_64

with 'ENGINE': 'django.db.backends.postgresql_psycopg2' I got :

[...]
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/postgresql_psycopg2/base.py", line 24, in <module>
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: /usr/local/lib/python2.6/dist-packages/psycopg2-2.4.4-py2.6-linux-x86_64.egg/psycopg2/_psycopg.so: undefined symbol: Py_InitModule4_64

And I shouldn't use psycopg with Python >2.6, right ?

Any help on how to do make this work ?

2 Answers 2

3

Try make a clean slate. Prepare separated virtualenv directory.

sudo apt-get install python-virtualenv  # if you don't have it yet 
virtualenv /some/dir/

Activate virtualenv

source /some/dir/bin/activate

Prepare django and psycopg2 and whatever other libraries you use

pip install psycopg2 django # possibly other libraries

And then move to your project directory (this with manage.py), make sure project is within PYTHONPATH and try ./manage.py runserver again.

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

1 Comment

Since my knowledge increased since I wrote this answer, now I would strongly advice to make familiar with virtualenvwrapper library: virtualenvwrapper.readthedocs.io/en/latest. It's easier to manager virtualenvs through it when you do initial setup.
1

Your installation is broken. Maybe you run a 32bit python but the library is for 64bit.

I run psycopg2 with Python2.7 without problems.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.