# Can not switch from sqlite to postgresql backend

**URL:** https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201
**Category:** User
**Created:** [January 18, 2020, 12:50pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201 "2020-01-18T12:50:21Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![ratatouille](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/57b2e6/32.png) [@ratatouille](https://discuss.tryton.org/u/ratatouille)
#### Post date: [January 18, 2020, 12:50pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/1 "2020-01-18T12:50:21Z")

</div>

Hmmm…  
At the moment I can’t login anymore with the client after I tried to deactivate sale\_stock\_quantity.

Traceback (most recent call last):  
File “/usr/bin/tryton”, line 67, in   
client.TrytonClient().run()  
File “/usr/lib/python2.7/dist-packages/tryton/client.py”, line 293, in run  
main.sig\_login()  
File “/usr/lib/python2.7/dist-packages/tryton/gui/main.py”, line 876, in sig\_login  
common.Login(func)  
File “/usr/lib/python2.7/dist-packages/tryton/common/common.py”, line 1050, in **init**  
func(parameters)  
File “/usr/lib/python2.7/dist-packages/tryton/gui/main.py”, line 873, in   
host, port, database, username, parameters, language)  
File “/usr/lib/python2.7/dist-packages/tryton/rpc.py”, line 72, in login  
result = connection.common.db.login(username, parameters, language)  
File “/usr/lib/python2.7/xmlrpclib.py”, line 1243, in **call**  
return self.\_\_send(self.\_\_name, args)  
File “/usr/lib/python2.7/dist-packages/tryton/jsonrpc.py”, line 296, in \_\_request  
raise Fault(\*response[‘error’])  
Fault: \<Fault u"‘res.user’": u’Traceback (most recent call last):\n File “/trytond/wsgi.py”, line 70, in dispatch\_request\n return endpoint(request, \*\*request.view\_args)\n File “/trytond/protocols/dispatcher.py”, line 41, in rpc\n request, database\_name, \*request.rpc\_params)\n File “/trytond/protocols/dispatcher.py”, line 54, in login\n database\_name, user, parameters, language=language)\n File “/trytond/security.py”, line 24, in login\n User = pool.get('res.user')\n File “/trytond/pool.py”, line 170, in get\n return self.\_pool[self.database\_name][type][name]\nKeyError: 'res.user'\n’\>

I think I will start from scratch with tryton and a postgresql database.

---

<div class="post-metadata">

### Author: ![bala4901](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/fbc32d/32.png) [@bala4901](https://discuss.tryton.org/u/bala4901)
#### Post date: [January 18, 2020, 1:05pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/2 "2020-01-18T13:05:38Z")

</div>

Have you tried trytond-admin -d database --all?

---

<div class="post-metadata">

### Author: ![ratatouille](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/57b2e6/32.png) [@ratatouille](https://discuss.tryton.org/u/ratatouille)
#### Post date: [January 18, 2020, 1:36pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/3 "2020-01-18T13:36:55Z")

</div>

trytond-admin -c /etc/tryton/trytond.conf -d tryton --all  
Traceback (most recent call last):  
File “/usr/bin/trytond-admin”, line 21, in   
admin.run(options)  
File “/usr/lib/python3/dist-packages/trytond/admin.py”, line 54, in run  
installdeps=options.installdeps)  
File “/usr/lib/python3/dist-packages/trytond/pool.py”, line 153, in init  
lang=lang, installdeps=installdeps)  
File “/usr/lib/python3/dist-packages/trytond/modules/ **init**.py”, line 472, in load\_modules  
\_load\_modules(update)  
File “/usr/lib/python3/dist-packages/trytond/modules/ **init**.py”, line 436, in \_load\_modules  
graph = create\_graph(module\_list)[0]  
File “/usr/lib/python3/dist-packages/trytond/modules/ **init**.py”, line 191, in create\_graph  
- set((p[0] for p in packages))))  
trytond.exceptions.MissingDependenciesException: [‘sale’]

---

<div class="post-metadata">

### Author: ![bala4901](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/fbc32d/32.png) [@bala4901](https://discuss.tryton.org/u/bala4901)
#### Post date: [January 18, 2020, 1:41pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/4 "2020-01-18T13:41:22Z")

</div>

Trying below:  
Pip install trytond-sale

Then update all module again

---

<div class="post-metadata">

### Author: ![ratatouille](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/57b2e6/32.png) [@ratatouille](https://discuss.tryton.org/u/ratatouille)
#### Post date: [January 18, 2020, 1:41pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/5 "2020-01-18T13:41:34Z")

</div>

At the moment I’m struggling with  
trytond-admin -c /etc/tryton/trytond.conf -d tryton --all  
after changing to postgresql and creating the database tryton with user postgres.

Traceback (most recent call last):  
File “/usr/lib/python3/dist-packages/trytond/backend/ **init**.py”, line 32, in get  
‘trytond.backend’, db\_type)  
ValueError: not enough values to unpack (expected 1, got 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “/usr/bin/trytond-admin”, line 21, in   
admin.run(options)  
File “/usr/lib/python3/dist-packages/trytond/admin.py”, line 20, in run  
Database = backend.get(‘Database’)  
File “/usr/lib/python3/dist-packages/trytond/backend/ **init**.py”, line 34, in get  
raise exception  
File “/usr/lib/python3/dist-packages/trytond/backend/ **init**.py”, line 26, in get  
**import** (modname)  
File “/usr/lib/python3/dist-packages/trytond/backend/postgresql/ **init**.py”, line 4, in   
from .database import \*  
File “/usr/lib/python3/dist-packages/trytond/backend/postgresql/database.py”, line 16, in   
from psycopg2 import connect, Binary  
ModuleNotFoundError: No module named ‘psycopg2’

---

<div class="post-metadata">

### Author: ![ratatouille](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/57b2e6/32.png) [@ratatouille](https://discuss.tryton.org/u/ratatouille)
#### Post date: [January 18, 2020, 1:48pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/6 "2020-01-18T13:48:00Z")

</div>

> [@Stock warning at sale](https://discuss.tryton.org/t/stock-warning-at-sale/2198/8):
>
> Pip install trytond-sale

Complete output from command python setup.py egg\_info:  
Traceback (most recent call last):  
File “”, line 1, in   
File “/tmp/pip-build-Pdd7e1/trytond-sale/setup.py”, line 8, in   
from configparser import ConfigParser  
ImportError: No module named configparser

```
----------------------------------------

```

Command “python setup.py egg\_info” failed with error code 1 in /tmp/pip-build-Pdd7e1/trytond-sale/

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 18, 2020, 1:50pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/7 "2020-01-18T13:50:14Z")

</div>

Looks like you are still using the unsupported Python 2.  
Tryton is Python 3 only.

---

<div class="post-metadata">

### Author: ![bala4901](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/fbc32d/32.png) [@bala4901](https://discuss.tryton.org/u/bala4901)
#### Post date: [January 18, 2020, 1:52pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/8 "2020-01-18T13:52:53Z")

</div>

Your environment may default using python2.

Can you try  
Pip3 install trytond-sale

---

<div class="post-metadata">

### Author: ![ratatouille](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/57b2e6/32.png) [@ratatouille](https://discuss.tryton.org/u/ratatouille)
#### Post date: [January 18, 2020, 1:53pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/9 "2020-01-18T13:53:14Z")

</div>

pip3 install trytond-sale  
Requirement already satisfied: trytond-sale in /usr/lib/python3/dist-packages

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 18, 2020, 2:02pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/10 "2020-01-18T14:02:47Z")

</div>

It looks like your database was initialized but with partially installed modules.  
Once all dependency modules are installed, you must run the update of the database with the option `--activate-dependencies` to ensure new dependencies are activated.

---

<div class="post-metadata">

### Author: ![ratatouille](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/57b2e6/32.png) [@ratatouille](https://discuss.tryton.org/u/ratatouille)
#### Post date: [January 18, 2020, 2:09pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/11 "2020-01-18T14:09:07Z")

</div>

trytond-admin -c /etc/tryton/trytond.conf -d tryton --activate-dependencies

trytond-admin: error: unrecognized arguments: --activate-dependencies

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 18, 2020, 2:09pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/12 "2020-01-18T14:09:53Z")

</div>

I think you are using a no more supported version of Tryton. You must use at least the series 5.0.

---

<div class="post-metadata">

### Author: ![ratatouille](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/57b2e6/32.png) [@ratatouille](https://discuss.tryton.org/u/ratatouille)
#### Post date: [January 18, 2020, 2:13pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/13 "2020-01-18T14:13:02Z")

</div>

Yes, v4.6.5, Linuxmint package. I was hoping to be able to upgrade to the latest version but maybe it’s better to start with the latest version from scratch. Sadly there seem to be not packages for Linuxmint.

---

<div class="post-metadata">

### Author: ![bala4901](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/fbc32d/32.png) [@bala4901](https://discuss.tryton.org/u/bala4901)
#### Post date: [January 18, 2020, 2:15pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/14 "2020-01-18T14:15:13Z")

</div>

Is there any reason you stick to 4.6.5?

Although no package, but installing from source of trytond should be easy also.  
Just clone the source code and the the root folder “python3 setup.py install” should already install.

---

<div class="post-metadata">

### Author: ![ratatouille](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/57b2e6/32.png) [@ratatouille](https://discuss.tryton.org/u/ratatouille)
#### Post date: [January 18, 2020, 2:22pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/15 "2020-01-18T14:22:27Z")

</div>

Yes, I will go this way. All that stuff is very new to me but tryton seems to be a very interesstingly project. I got the source of tryton-5.4.3.tar.gz trytond-5.4.3.tar.gz and tryton-sao-5.4.2.tgz and will install needed modules gradually.

---

<div class="post-metadata">

### Author: ![ratatouille](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/57b2e6/32.png) [@ratatouille](https://discuss.tryton.org/u/ratatouille)
#### Post date: [January 18, 2020, 2:58pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/16 "2020-01-18T14:58:26Z")

</div>

> [@bala4901](#):
>
> “python3 setup.py install”

“python3 setup.py install”  
ModuleNotFoundError: No module named ‘setuptools’

I have no clue with python.

---

<div class="post-metadata">

### Author: ![ratatouille](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/57b2e6/32.png) [@ratatouille](https://discuss.tryton.org/u/ratatouille)
#### Post date: [January 18, 2020, 3:00pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/17 "2020-01-18T15:00:18Z")

</div>

apt-get install python3-setuptools did the trick.

---

<div class="post-metadata">

### Author: ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)
#### Post date: [January 18, 2020, 4:23pm UTC](https://discuss.tryton.org/t/can-not-switch-from-sqlite-to-postgresql-backend/2201/18 "2020-01-18T16:23:11Z")

</div>

I would suggest to use a Python virtual environment. In that way you keep your OS clean and install everything inside that environment. You then can also use `pip` to install and upgrade the different trytond-\* packages and their dependencies.  
for `psycopg2` I always install the `psycopg2-binary` with pip (inside the environment) so no need for a compiler to compile the binary.
