Error while installation: CryptContext object has no attribute

Hello guys, I’m new at Tryton and trying since hours to get the installation of trytond 5.6 on Ubuntu 20 running.

I’m trying to run the command trytond-admin -c /etc/tryton/trytond.conf -d trytondb --all

After entering the user data, following error appears:

Traceback (most recent call last):
  File "/usr/local/bin/trytond-admin", line 23, in <module>
    admin.run(options)
  File "/usr/local/lib/python3.5/dist-packages/trytond/admin.py", line 114, in run
    admin.save()
  File "/usr/local/lib/python3.5/dist-packages/trytond/model/descriptors.py", line 31, in newfunc
    return self.func(owner, [instance], *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/trytond/model/modelstorage.py", line 1714, in save
    (([r], save_values[r]) for r in to_write), ()))
  File "/usr/local/lib/python3.5/dist-packages/trytond/res/user.py", line 379, in write
    super(User, cls).write(*args)
  File "/usr/local/lib/python3.5/dist-packages/trytond/model/modelsql.py", line 159, in wrapper
    return func(cls, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/trytond/model/modelsql.py", line 1013, in write
    field.set(cls, fname, *fargs)
  File "/usr/local/lib/python3.5/dist-packages/trytond/model/fields/function.py", line 122, in set
    setter(Model.browse(ids), name, value)
  File "/usr/local/lib/python3.5/dist-packages/trytond/res/user.py", line 255, in set_password
    'password_hash': cls.hash_password(value),
  File "/usr/local/lib/python3.5/dist-packages/trytond/res/user.py", line 670, in hash_password
    return CRYPT_CONTEXT.hash(password)
AttributeError: 'CryptContext' object has no attribute 'hash'

Already spent hours with looking for a solution. Any ideas how to fix the error?

Thanks in advance
–Chris

You do not seem to have the proper passlib library which contains CryptContext.hash.

Hello Chris,

I would suggest to install Tryton in a Python virtual environment with pip, so you leave your default system clean and untouched. When you mess up things, you can easily remove the virtual environment and start again with a clean slate.

If you are going with the virtual environment see if it is possible to reinstall Ubuntu as you are getting a lot of trouble because of the globally installed packages.

BTW. I’m in the process of creating a document how to install Tryton within a virtual environment which can be used as a base to build upon.

1 Like

Thank you so far for your responses. Did the installation of tryton as described here.

The command
pip3 install passlib

gets:
Requirement already satisfied: passlib in /usr/lib/python3/dist-packages (1.6.5)

same output when using pip3.5 install

–Chris

Have you tried pip3 install passlib --upgrade?

That’s the solution. After upgrading to passlib-1.7.2 everything works fine.

I’m excited to use Tryton now. Great community!

–Chris

Indeed the hash method was added on version 1.7.0. So I created Issue 9631: Required passlib >=1.7.0 - Tryton issue tracker.

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