AttributeError: 'NoneType' object has no attribute 'put_connection'

Hello, first of all, happy holidays, the problem I have is the following…
I have this code in a python file called

from flask import Flask, render_template, request, redirect, url_for
from flask_tryton import Tryton

import taller

app = Flask(__name__)
# conectarla a la bbdd
app.config['TRYTON_DATABASE'] = 'cars_db'
tryton = Tryton(app, configure_jinja=True)
Marca = tryton.pool.get('taller.marca')
Modelo = tryton.pool.get('taller.modelo')
Coche = tryton.pool.get('taller.coche')
Party = tryton.pool.get('')

def lista_coches():
    marcas =[])  # para que devuelva todos los registrospi
    return render_template('marca.html', marca=marcas)

The first thing I do is

  • export

Once done, I put it in development

  • export FLASK_ENV=development

and when I run

  • flask run

it gives me this error

osboxes@osboxes:~/prueba/taller$ flask run
Traceback (most recent call last):
  File "/home/osboxes/.local/bin/flask", line 8, in <module>
  File "/home/osboxes/.local/lib/python3.10/site-packages/flask/", line 1064, in main
  File "/home/osboxes/.local/lib/python3.10/site-packages/click/", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/osboxes/.local/lib/python3.10/site-packages/click/", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/osboxes/.local/lib/python3.10/site-packages/click/", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/osboxes/.local/lib/python3.10/site-packages/click/", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/osboxes/.local/lib/python3.10/site-packages/click/", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/osboxes/.local/lib/python3.10/site-packages/click/", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/osboxes/.local/lib/python3.10/site-packages/flask/", line 912, in run_command
    raise e from None
  File "/home/osboxes/.local/lib/python3.10/site-packages/flask/", line 898, in run_command
    app = info.load_app()
  File "/home/osboxes/.local/lib/python3.10/site-packages/flask/", line 313, in load_app
    app = locate_app(import_name, None, raise_if_not_found=False)
  File "/home/osboxes/.local/lib/python3.10/site-packages/flask/", line 219, in locate_app
  File "/home/osboxes/prueba/taller/", line 11, in <module>
    tryton = Tryton(app, configure_jinja=True)
  File "/home/osboxes/.local/lib/python3.10/site-packages/", line 51, in __init__
  File "/home/osboxes/.local/lib/python3.10/site-packages/", line 66, in init_app
    with Transaction().start(database, user, readonly=True):
  File "/home/osboxes/.local/lib/python3.10/site-packages/trytond/", line 218, in start
  File "/home/osboxes/.local/lib/python3.10/site-packages/trytond/", line 241, in stop
AttributeError: 'NoneType' object has no attribute 'put_connection'

I have tried connecting to the database and I have made a couple of SQL queries and it works, but I don’t know what I am failing here.

ok, I just saw what my mistake was, I have to load the address where my trytond.conf file is located

export TRYTON_CONFIG=/home/osboxes/trytond.conf

And now it works.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.