UnicodeDecodeError序号不在范围内(128)

时间:2017-08-29 18:43:38

标签: python django python-2.7 django-models

我刚刚安装了python 2.7.13和Django 1.11.4。 我创建了一个名为myproject的项目,并尝试从下面的命令开始,但它会抛出UnicodeDecodeError错误。

python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at 0x7f13229f10c8>
Traceback (most recent call last):
  File "/opt/IBM/Python2.6/lib/python2.7/site-packages/django/utils/autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "/opt/IBM/Python2.6/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 128, in inner_run
    self.check_migrations()
  File "/opt/IBM/Python2.6/lib/python2.7/site-packages/django/core/management/base.py", line 422, in check_migrations
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File "/opt/IBM/Python2.6/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/opt/IBM/Python2.6/lib/python2.7/site-packages/django/db/migrations/loader.py", line 52, in __init__
    self.build_graph()
  File "/opt/IBM/Python2.6/lib/python2.7/site-packages/django/db/migrations/loader.py", line 209, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/opt/IBM/Python2.6/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
    self.ensure_schema()
  File "/opt/IBM/Python2.6/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 59, in ensure_schema
    raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf1 in position 6: ordinal not in range(128)

我没有配置任何其他内容,只是尝试启动开发服务器但它失败了。

1 个答案:

答案 0 :(得分:0)

此错误表示

UnicodeDecodeError: 'ascii' codec can't decode byte 0xf1 in position 6: ordinal not in range(128)

表名中有非ascii字符。 0xf1通常是带有波浪号的拉丁小写字母n的扩展ASCII码。

严格的ASCII只有最多128个字符(0x80)。智能程序员意识到他们在分配给一个字符的1字节内存中有另外128个可能的值,因此他们创建了EXTENDED ASCII。但是每个人都有不同的想法,那就是导致CODEPAGES描述你的EXTENDED ASCII方案的原因。这一切都被UNICODE所取代,UNICODE允许所有真实和想象语言中的每个可能的字符都有自己独特的字节值。如何编码是各种规格的主题,例如UFT-8,UTF-16&amp; ISO-8859-1。

解决方案:从表名中删除违规字符,生活很美好。