'utf-8' не может декодировать байт 0xc0 в позиции 0: неверный стартовый байт - PullRequest
1 голос
/ 10 мая 2011

Я пытаюсь выполнить Duango createuperuser и получить следующую ошибку.Перед тем как база данных syncdb будет пустой и закодирована в 'utf-8'.Я использую pymysql.

D:\Python27\site\mysite>python manage.py syncdb
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site

You just installed Django's auth system, which means you don't have any superuse
rs defined.
Would you like to create one now? (yes/no): yes
Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "D:\python27\lib\site-packages\django\core\management\__init__.py", line
438, in execute_manager
    utility.execute()
  File "D:\python27\lib\site-packages\django\core\management\__init__.py", line
379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\python27\lib\site-packages\django\core\management\base.py", line 191,
 in run_from_argv
    self.execute(*args, **options.__dict__)
  File "D:\python27\lib\site-packages\django\core\management\base.py", line 220,
 in execute
    output = self.handle(*args, **options)
  File "D:\python27\lib\site-packages\django\core\management\base.py", line 351,
 in handle
    return self.handle_noargs(**options)
  File "D:\python27\lib\site-packages\django\core\management\commands\syncdb.py"
, line 109, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive, db)
  File "D:\python27\lib\site-packages\django\core\management\sql.py", line 190,
in emit_post_sync_signal
    interactive=interactive, db=db)
  File "D:\python27\lib\site-packages\django\dispatch\dispatcher.py", line 172,
in send
    response = receiver(signal=self, sender=sender, **named)
  File "D:\python27\lib\site-packages\django\contrib\auth\management\__init__.py
", line 70, in create_superuser
    call_command("createsuperuser", interactive=True)
  File "D:\python27\lib\site-packages\django\core\management\__init__.py", line
166, in call_command
    return klass.execute(*args, **defaults)
  File "D:\python27\lib\site-packages\django\core\management\base.py", line 220,
 in execute
    output = self.handle(*args, **options)
  File "D:\python27\lib\site-packages\django\contrib\auth\management\commands\cr
eatesuperuser.py", line 72, in handle
    User.objects.get(username=default_username)
  File "D:\python27\lib\site-packages\django\db\models\manager.py", line 132, in
 get
    return self.get_query_set().get(*args, **kwargs)
  File "D:\python27\lib\site-packages\django\db\models\query.py", line 344, in g
et
    num = len(clone)
  File "D:\python27\lib\site-packages\django\db\models\query.py", line 82, in __
len__
    self._result_cache = list(self.iterator())
  File "D:\python27\lib\site-packages\django\db\models\query.py", line 273, in i
terator
    for row in compiler.results_iter():
  File "D:\python27\lib\site-packages\django\db\models\sql\compiler.py", line 68
0, in results_iter
    for rows in self.execute_sql(MULTI):
  File "D:\python27\lib\site-packages\django\db\models\sql\compiler.py", line 73
5, in execute_sql
    cursor.execute(sql, params)
  File "D:\python27\lib\site-packages\django\db\backends\util.py", line 34, in e
xecute
    return self.cursor.execute(sql, params)
  File "D:\python27\lib\site-packages\django\db\backends\mysql\base.py", line 86
, in execute
    return self.cursor.execute(query, args)
  File "build\bdist.win32\egg\pymysql\cursors.py", line 96, in execute
  File "build\bdist.win32\egg\pymysql\connections.py", line 575, in escape
  File "build\bdist.win32\egg\pymysql\converters.py", line 22, in escape_item
  File "build\bdist.win32\egg\pymysql\converters.py", line 45, in escape_sequenc
e
  File "build\bdist.win32\egg\pymysql\converters.py", line 27, in escape_item
  File "D:\python27\lib\encodings\utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xc0 in position 0: invalid s
tart byte

1 Ответ

2 голосов
/ 10 мая 2011

Байт с кодом C0 является недействительным в кодированном тексте UTF-8. Я не знаю, откуда этот текст, но это либо недействительный UTF-8, либо ваш код ошибочно пытается обработать его как UTF-8.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...