Forums

cannot createsuper user in bash!!!

after running the create superuser command in bash , its asking the credentials and then this error is showing!

Traceback (most recent call last):
  File "manage.py", line 20, in <module>
    main()
  File "manage.py", line 16, in main
    execute_from_command_line(sys.argv)
  File "/usr/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3.8/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python3.8/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/lib/python3.8/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 61, in execute
    return super().execute(*args, **options)
  File "/usr/lib/python3.8/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python3.8/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 156, in handle
    self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
  File "/usr/lib/python3.8/site-packages/django/contrib/auth/models.py", line 162, in create_superuser
    return self._create_user(username, email, password, **extra_fields)
  File "/usr/lib/python3.8/site-packages/django/contrib/auth/models.py", line 144, in _create_user
    user.set_password(password)
  File "/usr/lib/python3.8/site-packages/django/contrib/auth/base_user.py", line 98, in set_password
    self.password = make_password(raw_password)
  File "/usr/lib/python3.8/site-packages/django/contrib/auth/hashers.py", line 78, in make_password
    return hasher.encode(password, salt)
  File "/usr/lib/python3.8/site-packages/django/contrib/auth/hashers.py", line 417, in encode
    return "%s$%s" % (self.algorithm, data.decode('ascii'))
AttributeError: 'str' object has no attribute 'decode'

that feels like you have some python 2 code that is running python 3.

How python2 has come into play? because here the version selected is 3.8 On my local computer I use python 3.8 Command that I run in bash is also python3.8 manage.py createsuperuser

Thanks for the details! It looks like @conrad might have misinterpreted the error message; having dug into this a bit, it looks like we have two different versions of bcrypt installed for Python 3.8, and it's picking up the wrong one. Could you try running this in Bash to force the right version to be used, and see if it helps?

pip3.8 install --user --force-reinstall bcrypt

Thanks a` lot @giles it workd!!!! thanks a lot!!!

Just a quick note to say that this issue has been fixed in our most recent system image, glastonbury. If you see a problem like this, check your system image and update it if necessary. This help page explains how to do that.