Search code examples
djangopython-3.xopenshiftopenshift-originopenshift-client-tools

Failed to create superuser in django on OpenShift


I'm trying to set up a django app on the OpenShift. Trying to create superuser, having entered username, email and passwords I get a following error:

TypeError: object supporting the buffer API required

Is it some package missing? Am I doing something wrong?
django version 2.0.7
python version 3.6.3

Full error message:

(app-root) sh-4.2$ python manage.py createsuperuser
Username: maciej
Email address: xxx@xxx
Password:
Password (again):
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/app-root/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/opt/app-root/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/app-root/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/app-root/lib/python3.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 59, in execute
    return super().execute(*args, **options)
  File "/opt/app-root/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
    output = self.handle(*args, **options)
  File "/opt/app-root/lib/python3.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 179, in handle
    self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
  File "/opt/app-root/lib/python3.6/site-packages/django/contrib/auth/models.py", line 161, in create_superuser
    return self._create_user(username, email, password, **extra_fields)
  File "/opt/app-root/lib/python3.6/site-packages/django/contrib/auth/models.py", line 143, in _create_user
    user.set_password(password)
  File "/opt/app-root/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 98, in set_password
    self.password = make_password(raw_password)
  File "/opt/app-root/lib/python3.6/site-packages/django/contrib/auth/hashers.py", line 80, in make_password
    return hasher.encode(password, salt)
  File "/opt/app-root/lib/python3.6/site-packages/django/contrib/auth/hashers.py", line 249, in encode
    hash = pbkdf2(password, salt, iterations, digest=self.digest)
  File "/opt/app-root/lib/python3.6/site-packages/django/utils/crypto.py", line 85, in pbkdf2
    return hashlib.pbkdf2_hmac(digest().name, password, salt, iterations, dklen)
  File "/opt/app-root/lib64/python3.6/hashlib.py", line 90, in inner
    return func(*args, **kwargs)
TypeError: object supporting the buffer API required

Solution

  • Thanks to Graham Gordon for pointing me to this issue: github.com/sclorg/s2i-python-container/issues/237

    In my case the easiest work-around was to change from Python 3.6 image to Python 3.5. It can be done through OpenShift's web console:

    Builds -> Choose relevant build -> Actions -> Edit -> Image Configuration