WSL中的Odoo 12-Psycopg2没有获得适用于PostgreSQL的正确端口 [英] Odoo 12 in WSL - Psycopg2 doesn't get the right Port for PostgreSQL

查看:287
本文介绍了WSL中的Odoo 12-Psycopg2没有获得适用于PostgreSQL的正确端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Windows 10 Pro中使用WSL在Ubuntu 18.04 LTS中安装了Odoo 12.

I have installed Odoo 12 in Ubuntu 18.04 LTS using WSL for windows 10 Pro.

一切似乎都很好并且服务正在运行,但是当我访问本地主机时,出现内部服务器错误,并且出现此错误:

Everything seems fine and service is running, but when I access the localhost I get Internal Server Error, and I get this error:

    2019-09-05 06:52:07,596 309 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
  File "/opt/odoo/.local/lib/python3.6/site-packages/werkzeug/serving.py", line 303, in run_wsgi
    execute(self.server.app)
  File "/opt/odoo/.local/lib/python3.6/site-packages/werkzeug/serving.py", line 291, in execute
    application_iter = app(environ, start_response)
  File "/opt/odoo/odoo/odoo/service/server.py", line 409, in app
    return self.app(e, s)
  File "/opt/odoo/odoo/odoo/service/wsgi_server.py", line 128, in application
    return application_unproxied(environ, start_response)
  File "/opt/odoo/odoo/odoo/service/wsgi_server.py", line 117, in application_unproxied
    result = odoo.http.root(environ, start_response)
  File "/opt/odoo/odoo/odoo/http.py", line 1320, in __call__
    return self.dispatch(environ, start_response)
  File "/opt/odoo/odoo/odoo/http.py", line 1293, in __call__
    return self.app(environ, start_wrapped)
  File "/opt/odoo/.local/lib/python3.6/site-packages/werkzeug/middleware/shared_data.py", line 220, in __call__
    return self.app(environ, start_response)
  File "/opt/odoo/odoo/odoo/http.py", line 1453, in dispatch
    self.setup_db(httprequest)
  File "/opt/odoo/odoo/odoo/http.py", line 1376, in setup_db
    httprequest.session.db = db_monodb(httprequest)
  File "/opt/odoo/odoo/odoo/http.py", line 1537, in db_monodb
    dbs = db_list(True, httprequest)
  File "/opt/odoo/odoo/odoo/http.py", line 1504, in db_list
    dbs = odoo.service.db.list_dbs(force)
  File "/opt/odoo/odoo/odoo/service/db.py", line 375, in list_dbs
    with closing(db.cursor()) as cr:
  File "/opt/odoo/odoo/odoo/sql_db.py", line 657, in cursor
    return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
  File "/opt/odoo/odoo/odoo/sql_db.py", line 171, in __init__
    self._cnx = pool.borrow(dsn)
  File "/opt/odoo/odoo/odoo/sql_db.py", line 540, in _locked
    return fun(self, *args, **kwargs)
  File "/opt/odoo/odoo/odoo/sql_db.py", line 608, in borrow
    **connection_info)
  File "/opt/odoo/.local/lib/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? - - -

PostgreSQL使用端口5433安装:

PostgreSQL is installed using port 5433:

Ver Cluster Port Status Owner    Data directory              Log file
10  main    5433 online postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log

我将conf文件\etc\odoo-server.conf中的端口从False更改为5433:

I changed the port in the conf file \etc\odoo-server.conf from False to 5433:

[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = False
db_port = 5433
db_user = odoo
db_password = False
logfile = /var/log/odoo/odoo-server.log
addons_path = /opt/odoo/addons,/opt/odoo/odoo/addons

但是,我遇到了同样的错误.似乎Psycopg2将该值用作默认端口5432,即使我在.conf文件中指定了它.

However, I get the same error. Seems Psycopg2 take the value as default port 5432 even I specified it in the .conf file.

有帮助吗? 谢谢

推荐答案

您的发行版(如我的发行版)可能在/tmp目录中创建了密钥. 我一直在使用的一种快速解决方法是:

Your distribution (like mine) probably makes the key in the /tmp directory. A quick workaround I've been using is:

mkdir /var/run/postgresql
ln -s /tmp/.s.PGSQL.5432(or 5433) /var/run/postgresql/

这篇关于WSL中的Odoo 12-Psycopg2没有获得适用于PostgreSQL的正确端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆