使用自定义配置文件运行Odoo 13但无法启动数据库。
./odoo-bin --addons-path=odoo/addons -d odoo_codingdodo --save --config=.odoorc_codingdodo
我已经更新了所有 Homebrew 软件包,重新安装了 Postgres,但这并不能帮助我解决这个问题。我正在使用另一个配置文件开发 Odoo 13,并且我正在使用 anaconda for python3.8、env 等...但是一旦我升级了我的 anaconda 软件包,我就无法使用它,所以我删除了所有 anaconda 软件包并且删除了 python3.9.. 最新版本并重新安装为新版本并使用 Pyenv 设置我的 python Virtualenv。克隆了 Odoo 13,但我无法使用自定义配置文件运行。
出现此错误
2021-12-14 03:38:55,157 2939 INFO ? odoo: Odoo version 13.0
2021-12-14 03:38:55,157 2939 INFO ? odoo: Using configuration file at /Users/thanseef/Odoo13/odoo/.odoorc_codingdodo
2021-12-14 03:38:55,157 2939 INFO ? odoo: addons paths: ['/Users/thanseef/Odoo13/odoo/odoo/addons', '/Users/thanseef/Library/Application Support/Odoo/addons/13.0']
2021-12-14 03:38:55,157 2939 INFO ? odoo: database: default@default:default
2021-12-14 03:38:55,164 2939 INFO ? odoo.sql_db: Connection to the database failed
Traceback (most recent call last):
File "/Users/thanseef/Odoo13/odoo/./odoo-bin", line 8, in <module>
odoo.cli.main()
File "/Users/thanseef/Odoo13/odoo/odoo/cli/command.py", line 60, in main
o.run(args)
File "/Users/thanseef/Odoo13/odoo/odoo/cli/server.py", line 178, in run
main(args)
File "/Users/thanseef/Odoo13/odoo/odoo/cli/server.py", line 142, in main
odoo.service.db._create_empty_database(db_name)
File "/Users/thanseef/Odoo13/odoo/odoo/service/db.py", line 98, in _create_empty_database
with closing(db.cursor()) as cr:
File "/Users/thanseef/Odoo13/odoo/odoo/sql_db.py", line 664, in cursor
return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
File "/Users/thanseef/Odoo13/odoo/odoo/sql_db.py", line 196, in __init__
self._cnx = pool.borrow(dsn)
File "/Users/thanseef/Odoo13/odoo/odoo/sql_db.py", line 547, in _locked
return fun(self, *args, **kwargs)
File "/Users/thanseef/Odoo13/odoo/odoo/sql_db.py", line 613, in borrow
result = psycopg2.connect(
File "/Users/thanseef/.pyenv/versions/odoo-13_env/lib/python3.9/site-packages/psycopg2/__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: connection to server on socket "/tmp/.s.PGSQL.5432" failed: fe_sendauth: no password supplied
如果它可以帮助其他发现此问题的人,我通过以下方法解决了此错误:
pip install python-dotenv
import os
import sys
from dotenv import load_dotenv
load_dotenv()
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
.env
中保存的环境变量):def db_conn():
conn = psycopg2.connect(
host=os.getenv("POSTGRES_HOST"),
database=os.getenv("POSTGRES_DB"),
user=os.getenv("POSTGRES_USER"),
password=os.getenv("POSTGRES_PASSWORD")
)
与 docker 类似的连接问题。
psycopg2.OperationalError: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
通过在 sql 和 odoo 之间共享相同的 /var/run/postgresql 来解决
odoo:
volumes:
- ./postgresqlrun:/var/run/postgresql
....
psql:
volumes:
- ./postgresqlrun:/var/run/postgresql