Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

[SOLVED] Wsgi troubles

By
Mario Menezes
on 12/3/14, 5:36 AM 1,757 views

I'm trying to run Odoo in a virtualenv. I've done this for other Python apps so I followed the same recipe. 

My openerp-wsgi.py looks like:

import os
import sys
import site
sys.path.insert(0,'/home/futuracode/projects/odoo/')
sys.path.insert(1,'/home/futuracode/.virtualenvs/odoo/lib/python2.7/site-packages')
site.addsitedir('/home/futuracode/.virtualenvs/odoo/lib/python2.7/site-packages')
activate_this = os.path.expanduser("~/.virtualenvs/odoo/bin/activate_this.py")
execfile(activate_this, dict(__file__=activate_this))
project="/home/futuracode/projects/odoo"
workspace=os.path.dirname(project)
sys.path.append(workspace)
import openerp
openerp.multi_process = True # Nah!
openerp.conf.server_wide_modules = ['web']
conf = openerp.tools.config
conf['addons_path'] = '/home/futuracode/projects/odoo/addons,/home/futuracode/projects/odoo/openerp/addons'
conf['db_name'] = 'BLAH'
conf['database'] = 'BLAH'
conf['db_host'] = 'localhost'
conf['db_user'] = 'USERBLAH'
conf['db_port'] = PORTNUMBER
conf['db_password'] = 'SECRET'
conf['logfile'] = '/home/futuracode/projects/logs/odoo_gestao.log'
application = openerp.service.wsgi_server.application
openerp.service.server.load_server_wide_modules()
bind = '127.0.0.1:8069'
pidfile = '.gunicorn.pid'
workers = 4
timeout = 240
max_requests = 2000

When I try to access the application, I see this in the logs:

Wed Dec 03 10:22:24 2014] [error] [client 127.0.0.1]     from dateutil.relativedelta import relativedelta
[Wed Dec 03 10:22:24 2014] [error] [client 127.0.0.1] ImportError: cannot import name relativedelta

I've googled a little bit and couldn't find any solution that applies to this specific problem since most of them are related to wrong python version (2.6 instead of 2.7), wrong python-dateutil version, or wrong PYTHONPATH.

My configs are:

[Wed Dec 03 10:09:57 2014] [notice] Apache/2.2.25 (Unix) mod_wsgi/3.5 Python/2.7.8 configured -- resuming normal operations

$ pip freeze | grep dateutil
python-dateutil==1.5

Any help on this? Thanks in advance.

 

 

0
Andy Torres
On 5/12/16, 3:04 PM

Greetings Mario, I've been trying to set up the server, but without virtual env, and it always throws me the same error: 

ImportError: No module named openerp

Is it mandatory to set up a virtual environment? Do I need to perform any other steps if I don't have a virtual env set up?

Thanks in advance

0
Mario Menezes
On 12/4/14, 5:35 AM

Thanks to the terrific Webfaction support, my app is now running!

It was a overconfiguration problem!

I've put too much path infos in both the apache2 configuration httpd.conf and in my openerp-wsgi.py files when trying to solve my problem and that caused conflicts between the calendar module in addons and the dateutil calendar.

Removing all those extra lines and leaving only the absolutely neccessary, everything worked as expected.

My openerp-wsgi.py file now looks like:

import openerp
openerp.multi_process = True # Nah!
openerp.conf.server_wide_modules = ['web']
conf = openerp.tools.config
conf['addons_path'] = '/home/futuracode/projects/odoo/addons,/home/futuracode/projects/odoo/openerp/addons'
conf['db_name'] = 'BLODOH'
conf['database'] = 'BLODOH'
conf['db_host'] = 'localhost'
conf['db_user'] = 'BLODOH'
conf['db_port'] = PORTN
conf['db_password'] = 'TOPSECRET'
conf['logfile'] = '/home/futuracode/projects/logs/odoo_gestao.log'
application = openerp.service.wsgi_server.application
openerp.service.server.load_server_wide_modules()
bind = '127.0.0.1:8069'
pidfile = '.gunicorn.pid'
workers = 4
timeout = 240
max_requests = 2000

As you can see, no more sys.path or site.addsitedir. Nothing is really need if you point to right Python home in httpd.conf

And in the httpd.conf file, the relevant lines are:

WSGIPythonHome /PATH/TO/YOUR/VIRTUALENV/BASELINE/DIR
WSGIDaemonProcess oe user=futuracode processes=2  python-path=/PATH/TO/ODOO threads=1

 

Just one more remark: I'm using virtualenv, and all Python Odoo requirements are installed in the above /PATH/TO/YOUR/VIRTUALENV/BASELINE/DIR 

That is it!

Hope this can help someone in future!

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/3/14, 5:36 AM
Seen: 1757 times
Last updated: 5/12/16, 3:04 PM