I have installed Trytond server using pip in windows 10 and I also installed postgresql on windows 10. I would like to know do it need to create new config file name trytond.conf or use the config.py located under Trytond for database connection.
Yes you need to create a new config file. You can name it what you want, but most of the time it’s called trytond.conf. In that file at minimum you have
[database]
uri = postgresql://<postgreUser>:<postgrePassword>@localhost:5432/
path = C:\Users\<username>\<location>\<of_your>\<install>
Then you use the config file in your start command.
Check How install Tryton in Windows 10? (Regular and Anaconda) - #7 by edbo . In short, Windows doesn’t recognize the commands, you have to use the path where the command is and use python before to make sure Python is used to execute the file.
If you have Tryton server installed in a virtual environment you will find it as described in the link. If you have Tryton server installed globally, it will be in the site-packages directory of your Python installation. No idea where it actually is, so do a search for trytond-admin.
I am able to run tryton-admin command.
i added uri = postgresql://tryton:P@ssw0rd@localhost:5432/
and path = E:\Tryton\env\tryton_server\Lib\site-packages\trytond
I m getting multiple errors as mentioned below
(tryton_server) E:\Tryton\env\tryton_server\Scripts>python trytond-admin -c E:\Tryton\env\tryton_server\Lib\site-packages\trytond\trytond-conf.conf -d tryton --all
E:\Tryton\env\tryton_server\lib\site-packages\trytond\__init__.py:17: UserWarning: Timezone must be set to UTC instead of Arabian Standard Time
warnings.warn('Timezone must be set to UTC instead of %s' % time.tzname[0])
Exception in thread Thread-1 (dumper):
Traceback (most recent call last):
File "C:\Users\amishd\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner
self.run()
File "C:\Users\amishd\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run
self._target(*self._args, **self._kwargs)
File "E:\Tryton\env\tryton_server\lib\site-packages\trytond\status.py", line 69, in dumper
if dump(path):
File "E:\Tryton\env\tryton_server\lib\site-packages\trytond\status.py", line 52, in dump
sock = socket.socket(socket.AF_UNIX)
AttributeError: module 'socket' has no attribute 'AF_UNIX'
could not load E:\Tryton\env\tryton_server\Lib\site-packages\trytond\trytond-conf.conf
Traceback (most recent call last):
File "E:\Tryton\env\tryton_server\Scripts\trytond-admin", line 23, in <module>
admin.run(options)
File "E:\Tryton\env\tryton_server\lib\site-packages\trytond\admin.py", line 27, in run
database.connect()
File "E:\Tryton\env\tryton_server\lib\site-packages\trytond\backend\sqlite\database.py", line 359, in connect
self._make_uri(), uri=True,
File "E:\Tryton\env\tryton_server\lib\site-packages\trytond\backend\sqlite\database.py", line 433, in _make_uri
raise IOError("Database '%s' doesn't exist!" % db_path)
OSError: Database 'C:\Users\amishd\db/tryton.sqlite' doesn't exist!
Thanks for the reply. I tried changing the normal text file to ini file and also tried giving full administrator rights. Still persist same error.
My ini file details below:-
# Listen on all interfaces (IPv4)
listen = 0.0.0.0:8000
# Listen on all interfaces (IPv4 and IPv6)
#listen = [::]:8000
# The hostname for this interface
hostname = tryton.imtac.om
# The root path to retrieve data for GET requests
# (i.e. namely the path to the web client)
# (Internal default: /var/www/localhost/tryton)
#root = /usr/share/tryton-sao/www
root = /var/www/tryton-sao
[database]
uri = postgresql://tryton:P@ssw0rd@localhost:5432/
path = E:\Tryton\env\tryton_server\Lib\site-packages\trytond
language = en
[request]
request (zero means no limit).
[ssl]
[session]
[password]
# The minimal length required for user passwords.
#length = 8
# The path to a file containing one forbidden password per line.
#forbidden =
# The ratio of non repeated characters for user passwords.
#entropy = 0.75
# The time (in seconds) until a reset password expires.
#reset_timeout = 86400 # (24h)
# The path to the INI file to load as CryptContext:
Again, Tryton cannot find your config file E:\Tryton\env\tryton_server\Lib\site-packages\trytond\trytond-conf.conf. Check if that file actually exists and have the right content. Because Tryton cannot find your config file, it will fall back to it’s defaults which is a SQlite database, but it cannot find that one either, hence the OSError: Database 'C:\Users\amishd\db/tryton.sqlite' doesn't exist!
I suspect you have created a virtual environment because I see env in your path. I would create a config file in the root of the virtual environment (E:\Tryton\env\tryton_server).
I tested it myself just yet and I didn’t need to have the double \
After looking a bit closer, the error says “could not load”. So make sure you config file have the right content. It should work with only the following content:
[database]
uri = postgresql://tryton:P@ssw0rd@localhost:5432/
path = E:\Tryton\env\tryton_server\Lib\site-packages\trytond
Yes I have created on virtual environment. I have modified the config file and also added under tryton-server and also change the server from postgresql to postgresql 9.6.
[database]
# Database related settings
uri = PostgreSQL 9.6://tryton:P@ssw0rd@localhost:5432/
path = E:\Tryton\env\tryton_server\Lib\site-packages\trytond
It is bypassing the database connection error and now it is giving different error as mentioned below
E:\Tryton\env\tryton_server\lib\site-packages\trytond\__init__.py:17: UserWarning: Timezone must be set to UTC instead of Arabian Standard Time
warnings.warn('Timezone must be set to UTC instead of %s' % time.tzname[0])
Exception in thread Thread-1 (dumper):
Traceback (most recent call last):
File "C:\Users\amishd\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner
self.run()
File "C:\Users\amishd\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run
self._target(*self._args, **self._kwargs)
File "E:\Tryton\env\tryton_server\lib\site-packages\trytond\status.py", line 69, in dumper
if dump(path):
File "E:\Tryton\env\tryton_server\lib\site-packages\trytond\status.py", line 52, in dump
sock = socket.socket(socket.AF_UNIX)
AttributeError: module 'socket' has no attribute 'AF_UNIX'
Traceback (most recent call last):
File "E:\Tryton\env\tryton_server\scripts\trytond-admin", line 21, in <module>
import trytond.admin as admin
File "E:\Tryton\env\tryton_server\lib\site-packages\trytond\admin.py", line 11, in <module> from trytond import backend
File "E:\Tryton\env\tryton_server\lib\site-packages\trytond\backend\__init__.py", line 21, in <module> _module = importlib.import_module(_modname)
File "C:\Users\amishd\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ModuleNotFoundError: No module named 'trytond.backend.'
After changing Postgresql 9.6 to Postgresql I am getting different errors:
14292 8248 [2022-03-20 11:59:29,617] ERROR trytond.backend.postgresql.database connection to "tryton" failed
Traceback (most recent call last):
File "E:\Tryton\env\tryton_server\lib\site-packages\trytond\backend\postgresql\database.py", line 228, in __new__
inst._connpool = ThreadedConnectionPool(
File "E:\Tryton\env\tryton_server\lib\site-packages\psycopg2\pool.py", line 161, in __init__
AbstractConnectionPool.__init__(
File "E:\Tryton\env\tryton_server\lib\site-packages\psycopg2\pool.py", line 59, in __init__
self._connect()
File "E:\Tryton\env\tryton_server\lib\site-packages\psycopg2\pool.py", line 63, in _connect
conn = psycopg2.connect(*self._args, **self._kwargs)
File "E:\Tryton\env\tryton_server\lib\site-packages\psycopg2\__init__.py", line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not translate host name "ssw0rd@localhost" to address: Unknown server error
If you have reserved char in your username or password, you must encode them in the URI. So here the @ in the password must be encode as %40: see Percent-encoding - Wikipedia