Servicios > English support (For non-Spaniard users)
Problem with setting up django app
Lwoo:
Hi,
I've been trying to deploy my django project at monfloo.com, but got error 500. Actually I'm not sure what to do about that. :/
Also, I use PostgreSQL as my database. Trying to syncdb, I get "Error loading psycopg module: No module named psycopg". Not sure if I'm able to install the module myself (can't see virtualenv/virtualenvwrapper installed on the server, and easy_install needs root privileges) or just I have something configured improperly?
In general, the project is set up according to the guidelines from http://quijost.com/foro/desarrollo-web/ejemplo-de-prueba-index-py-para-django-y-mysql-con-mod_wgsi/ and https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/ (without the http.conf part of course ;)). However, I've run out of ideas what might be missing or done wrong. :/
shakaran:
Hi and welcome Lwoo,
We just installed psycopg2 v2.4.4 on server1 for give support to you. If you need some other module, just let me know.
When you write "import psycopg2" you need set previously the enviroment variable PYTHON_EGG_CACHE, for example:
--- Código: ---import os
os.environ['PYTHON_EGG_CACHE'] = '/home/youruser/tmp/trac-eggs'
import psycopg2
--- Fin del código ---
It is important that you must set PYTHON_EGG_CACHE under you username folder. The folder /tmp is not writeable for some reason to python when it loads internal imports and you could get a error similar to (or error 500):
--- Código: ---Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/psycopg2-2.4.4-py2.7-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.7/site-packages/psycopg2-2.4.4-py2.7-linux-x86_64.egg/psycopg2/_psycopg.so: undefined symbol: lo_truncate
--- Fin del código ---
Regarding to error 500, the error_log by apache for cPanel is general, so the only way that I know to catch 500 errors is wrapper the code with a try/catch exception like:
--- Código: ---filename = 'error_log.txt'
f = open(filename, 'w')
try:
# Do something with your code here
f.write('Ok')
except:
traceback.print_exc(file=f)
f.close()
--- Fin del código ---
Also searching on the general error_log I see this error for your site:
--- Código: ---[Thu Mar 08 23:36:18 2012] [alert] [client XXX.XXX.XXX.XXX] /home/monfloo/public_html/monfloo-landing/.htaccess: Invalid command 'PythonHandler', perhaps misspelled or defined by a module not included in the server configuration
[Thu Mar 08 23:36:18 2012] [alert] [client XXX.XXX.XXX.XXX] /home/monfloo/public_html/monfloo-landing/.htaccess: Invalid command 'PythonHandler', perhaps misspelled or defined by a module not included in the server configuration
[Thu Mar 08 23:36:18 2012] [error] Optional hook test said: GET / HTTP/1.0
[Thu Mar 08 23:36:18 2012] [error] Optional function test said: GET / HTTP/1.0
[Thu Mar 08 19:36:19 2012] [alert] [client XXX.XXX.XXX.XXX] /home/monfloo/public_html/monfloo-landing/.htaccess: Invalid command 'PythonHandler', perhaps misspelled or defined by a module not included in the server configuration
[Thu Mar 08 19:36:19 2012] [alert] [client XXX.XXX.XXX.XXX] /home/monfloo/public_html/monfloo-landing/.htaccess: Invalid command 'PythonHandler', perhaps misspelled or defined by a module not included in the server configuration
--- Fin del código ---
Note that PythonHandler directive is only for mod_python and we are using mod_wsgi for python scripts that works with "SetHandler wsgi-script"
Please fix that and back to me again if you need more assistance.
Lwoo:
Modified my settings.py to use psycopg2 and now got the following error message:
--- Código: ---monfloo@monfloo.quijost.com [~/monfloo-lp/monfloo_lp]# python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/cor
e/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/cor
e/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/cor
e/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/cor
e/management/__init__.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/uti
ls/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/cor
e/management/commands/syncdb.py", line 7, in <module>
from django.core.management.sql import custom_sql_for_model, emit_post_sync_
signal
File "/usr/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/cor
e/management/sql.py", line 6, in <module>
from django.db import models
File "/usr/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/db/
__init__.py", line 78, in <module>
connection = connections[DEFAULT_DB_ALIAS]
File "/usr/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/db/
utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "/usr/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/db/
utils.py", line 33, in load_backend
return import_module('.base', backend_name)
File "/usr/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/uti
ls/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/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.7/site-packages/psycopg2-2.4.4-py2.7-linux-x86_64.egg/psycopg
2/_psycopg.so: undefined symbol: lo_truncate
monfloo@monfloo.quijost.com [~/monfloo-lp/monfloo_lp]#
--- Fin del código ---
shakaran:
I test on our sandbox example too http://quijost.com/sandbox/index.py
And I am getting a error like:
/usr/local/lib/python2.7/site-packages/psycopg2-2.4.4-py2.7-linux-x86_64.egg/psycopg2/_psycopg.so: undefined symbol: lo_truncate
On google a lot people complains about the error, but without a workaround. The most precise info that I could get was:
http://archives.postgresql.org/psycopg/2011-10/msg00020.php
--- Citar ---lo_truncate is available after postgres 8.3. Psycopg is being compiled
again libpq 8.4, so the function is included. Looks like at runtime it
tries to dynamically link with an older libpq: you can check with ldd
which one.
--- Fin de la cita ---
So I gonna try debug and search on source code for make some changes on psycopg2 ang get it make available on postgres 9.1. But I cannot guarantee that I can make it work, seems a bug related with psycopg2.
While I try to fix, you could use MySqldb as a fallback alternative.
Lwoo:
OK, I sticked to MySQL for the time being and managed to initiate syncdb, but another error appeared: https://gist.github.com/9d1de002073de9b974ae
Navegación
[#] Página Siguiente
Ir a la versión completa