Django and PostgreSQL problems; python-psycopg

Hello,

I noticed that when trying to deploy a django application and selecting postgresql for the database type, that the install fails because it is looking for python-psycopg. However, there is now a python-psycopg2 which comes installed on centos servers. The module it is looking for is very old and outdated.

I looked in the django.pl perl script for anything related to python-psycopg to see if I could change it so it would attempt to install and/or use python-psycopg2 instead of v.1 but can not find it.

My question is, can you point me in the right direction on which file needs to be modified so that django can then deploy correctly using your django.pl script? Or is it possible you all release a bug fix for this? I appreciate the work your team does.

The below is an example of what happens when you click on the django installation and selected postgresql as your database type.

Installing package(s) with command yum -y install python-psycopg .. Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.loosefoot.com * epel: mirror.compevo.com * extras: mirror.raystedman.net * rpmforge: mirror.team-cymru.org * updates: mirrors.centarra.com Setting up Install Process No package python-psycopg available. Error: Nothing to do .. install failed!

Status: 
Closed (fixed)

Comments

If you manually install the python-psycopg2 package first, is Virtualmin able to correctly install Django?

No it's unable to. I already have python-psycopg2 installed. But virtualmin is looking for python-psycopg (Version 1, not 2)

I have also tried to install python-psycopg but believe it may not be the safest route since that is outdated. Is there anything in the install script that is calling for python-psycopg that you know of so I can modify it and have it look for python-psycopg2? Or do you have any other suggestions

So what I am wondering is, is the Python module still named "psycopg" even for version 2?

You can test this by manually installing "python-psycopg2" RPM, and then running :

echo import psycopg | python

and see what error it reports.

No, as I mentioned above it is not.

[root@ns3 ~]# echo import psycopg | python Traceback (most recent call last): File "", line 1, in ImportError: No module named psycopg [root@ns3 ~]#

Ok, but does this work :

echo import psycopg2 | python

Yes that works I believe. When I do it, no errors come back.

[root@ns3 ~]# echo import psycopg2 | python [root@ns3 ~]#

Ok, cool - so what I'll do in the next Virtualmin release is have the Django installer look for psycopg2 instead of psycopg .

Ok great. I appreciate it. Do you know when the new django.pl will be available for download?

On line 43 of the django.pl script, I see:

return ( "setuptools", $dbtype eq "mysql" ? "MySQLdb" : "psycopg" );

But when I change the last part of that line from "psycopg" to "psycopg2", the script still looks for psycopg. Am I looking in the right place?

Thank you as always Jamie for your help. Please let me know where I can send a payment to for your dedication and hard work

Actually, changing it on both django.pl files did resolve the first issue. The script is looking for (and also successfully finding) psycopg2 . Now, this is the error that is received. It seems to be related to something getting called in to early:

Now installing Django version 1.6.2 ..

Database initialization failed at yes.no : Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/home/mypy/public_html/lib/python/django/core/management/init.py", line 399, in execute_from_command_line utility.execute() File "/home/mypy/public_html/lib/python/django/core/management/init.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/mypy/public_html/lib/python/django/core/management/base.py", line 242, in run_from_argv self.execute(*args, **options.__dict__) File "/home/mypy/public_html/lib/python/django/core/management/base.py", line 280, in execute translation.activate('en-us') File "/home/mypy/public_html/lib/python/django/utils/translation/__init__.py", line 130, in activate return _trans.activate(language) File "/home/mypy/public_html/lib/python/django/utils/translation/trans_real.py", line 188, in activate _active.value = translation(language) File "/home/mypy/public_html/lib/python/django/utils/translation/trans_real.py", line 177, in translation default_translation = _fetch(settings.LANGUAGE_CODE) File "/home/mypy/public_html/lib/python/django/utils/translation/trans_real.py", line 159, in _fetch app = import_module(appname) File "/home/mypy/public_html/lib/python/django/utils/importlib.py", line 40, in import_module __import__(name) File "/home/mypy/public_html/lib/python/django/contrib/admin/__init__.py", line 6, in from django.contrib.admin.sites import AdminSite, site File "/home/mypy/public_html/lib/python/django/contrib/admin/sites.py", line 4, in from django.contrib.admin.forms import AdminAuthenticationForm File "/home/mypy/public_html/lib/python/django/contrib/admin/forms.py", line 6, in from django.contrib.auth.forms import AuthenticationForm File "/home/mypy/public_html/lib/python/django/contrib/auth/forms.py", line 17, in from django.contrib.auth.models import User File "/home/mypy/public_html/lib/python/django/contrib/auth/models.py", line 48, in class Permission(models.Model): File "/home/mypy/public_html/lib/python/django/db/models/base.py", line 96, in __new__ new_class.add_to_class('_meta', Options(meta, **kwargs)) File "/home/mypy/public_html/lib/python/django/db/models/base.py", line 264, in add_to_class value.contribute_to_class(cls, name) File "/home/mypy/public_html/lib/python/django/db/models/options.py", line 124, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "/home/mypy/public_html/lib/python/django/db/__init__.py", line 34, in __getattr__ return getattr(connections[DEFAULT_DB_ALIAS], item) File "/home/mypy/public_html/lib/python/django/db/utils.py", line 198, in __getitem__ backend = load_backend(db['ENGINE']) File "/home/mypy/public_html/lib/python/django/db/utils.py", line 131, in load_backend raise ImproperlyConfigured(error_msg) django.core.exceptions.ImproperlyConfigured: 'django.db.backends.postgresql' isn't an available database backend. Try using 'django.db.backends.XXX', where XXX is one of: u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3' Error was: No module named postgresql.base

Ok, it looks like Virtualmin isn't setting the postgresql driver type properly in the DJango config. I'll fix that in the next release.

Automatically closed -- issue fixed for 2 weeks with no activity.