gpt4 book ai didi

python - Django non-rel createsuperuser 由于非 ascii 字符而失败

转载 作者:太空宇宙 更新时间:2023-11-03 19:25:43 25 4
gpt4 key购买 nike

我正在尝试在我的 django 应用程序引擎项目上创建一个新的 super 用户,以便访问内置的管理功能。每次当我运行时

python manage.py createsuperuser

我收到一条错误消息““'NoneType'对象没有属性'mkstemp'””

我尝试重新安装 django python 和应用程序引擎 sdk,但没有成功,我将项目移动到路径中没有非 ascii 字母的目录中,因为我担心这可能是问题的原因,再次,运气不好...我没有主意...

这是抛出异常的完整回溯:

Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "C:\empeeric\pickadeal\django\core\management\__init__.py", line 438, in execute_manager
utility.execute()
File "C:\empeeric\pickadeal\django\core\management\__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\empeeric\pickadeal\django\core\management\base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\empeeric\pickadeal\django\core\management\base.py", line 220, in execute
output = self.handle(*args, **options)
File "C:\empeeric\pickadeal\django\contrib\auth\management\commands\createsuperuser.py", line 72, in handle
User.objects.get(username=default_username)
File "C:\empeeric\pickadeal\django\db\models\manager.py", line 132, in get
return self.get_query_set().get(*args, **kwargs)
File "C:\empeeric\pickadeal\django\db\models\query.py", line 346, in get
num = len(clone)
File "C:\empeeric\pickadeal\django\db\models\query.py", line 82, in __len__
self._result_cache = list(self.iterator())
File "C:\empeeric\pickadeal\django\db\models\query.py", line 275, in iterator
for row in compiler.results_iter():
File "C:\empeeric\pickadeal\djangotoolbox\db\basecompiler.py", line 229, in results_iter
for entity in self.build_query(fields).fetch(low_mark, high_mark):
File "C:\empeeric\pickadeal\djangotoolbox\db\basecompiler.py", line 289, in build_query
query.add_filters(self.query.where)
File "C:\empeeric\pickadeal\djangotoolbox\db\basecompiler.py", line 74, in add_filters
self.add_filters(child)
File "C:\empeeric\pickadeal\djangotoolbox\db\basecompiler.py", line 78, in add_filters
self.add_filter(column, lookup_type, self._negated, db_type, value)
File "C:\empeeric\pickadeal\djangoappengine\db\compiler.py", line 61, in _func
return func(*args, **kwargs)
File "C:\empeeric\pickadeal\djangoappengine\db\compiler.py", line 271, in add_filter
self._add_filter(column, op, db_type, value)
File "C:\empeeric\pickadeal\djangoappengine\db\compiler.py", line 279, in _add_filter
value = self.convert_value_for_db(db_type, value)
File "C:\empeeric\pickadeal\djangotoolbox\db\basecompiler.py", line 209, in convert_value_for_db
return self.compiler.convert_value_for_db(db_type, value)
File "C:\empeeric\pickadeal\djangoappengine\db\compiler.py", line 445, in convert_value_for_db
value = value.decode('utf-8') if isinstance(value, str) else value
File "C:\hp\bin\Python\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-4: unsupported Unicode code range
Exception exceptions.AttributeError: "'NoneType' object has no attribute 'mkstemp'" in <bound method DatastoreFileStub.__del__ of <google.appengine.api.datasto
e_file_stub.DatastoreFileStub object at 0x02277890>> ignored

有人吗?

最佳答案

由于您没有向它传递任何参数,createsuperuser.py 使用 Python getpass 模块来获取默认用户名。 (第 59 行,createsuperuser.py):

        # Try to determine the current system user's username to use as a default.
try:
default_username = getpass.getuser().replace(' ', '').lower()
except (ImportError, KeyError):
# KeyError will be raised by os.getpwuid() (called by getuser())
# if there is no corresponding entry in the /etc/passwd file
# (a very restricted chroot environment, for example).
default_username = ''

在我看来 getpass.getuser() 没有返回可以由 Python 的 UTF-8 解码器解码的字符串。我的猜测是您的 Windows 安装上的默认用户名是用一些较旧的非 unicode 8 位编码进行编码的。也许您的默认 Windows 用户名中有一些重音字符,例如?

这个错误显然已经在 Django 的主分支上报告了,因此也许这里记录的解决方法之一可以为您解决问题:

https://code.djangoproject.com/ticket/15778

关于python - Django non-rel createsuperuser 由于非 ascii 字符而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8210653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com