无法在 OpenShift 上的 Django 中创建超级用户

Failed to create superuser in django on OpenShift

我正在尝试在 OpenShift 上设置一个 django 应用程序。 尝试创建超级用户,输入用户名、电子邮件和密码后出现以下错误:

TypeError: object supporting the buffer API required

是不是少了什么包裹?我做错了什么吗?
django 版本 2.0.7
python 版本 3.6.3

完整的错误信息:

(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

感谢 Graham Gordon 指出我这个问题: github.com/sclorg/s2i-python-container/issues/237

就我而言,最简单的解决方法是将 Python 3.6 图像更改为 Python 3.5。可以通过 OpenShift 的 Web 控制台完成:

构建 -> 选择相关构建 -> 操作 -> 编辑 -> 图像配置