[英]AttributeError: module 'six' has no attribute 'memoryview' occurs when configuring django database for django-mssql
My Django is the latest version, python3.8.我的Django是最新版本,python3.8。 I want to configure the database for sql server 2008 R2, so I install django-mssql(aka,sqlserver_ado).
我想为 sql server 2008 R2 配置数据库,所以我安装了 django-mssql(aka,sqlserver_ado)。 After running the server, an error occurs:
运行服务器后,出现错误:
.........
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Program Files\Python38\lib\site-packages\sqlserver_ado\base.py", line
13, in <module>
from . import dbapi as Database
File "C:\Program Files\Python38\lib\site-packages\sqlserver_ado\dbapi.py", lin
e 45, in <module>
from django.utils import six
ImportError: cannot import name 'six' from 'django.utils' (C:\Program Files\Pyth
on38\lib\site-packages\django\utils\__init__.py)
Following this suggestion ,按照这个建议,
I open "C:\Program Files\Python38\lib\site-packages\sqlserver_ado\dbapi.py" and change " from django.utils import six
" to " import six
", as well as upgrading the six module to latest version.我打开“C:\Program Files\Python38\lib\site-packages\sqlserver_ado\dbapi.py”并将“
from django.utils import six
”更改为“ import six
”,并将六模块升级到最新版本。
And this time another Error raised:这一次引发了另一个错误:
......
File "C:\Program Files\Python38\lib\site-packages\django\db\utils.py", line 20
7, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Program Files\Python38\lib\site-packages\django\db\utils.py", line 11
1, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Program Files\Python38\lib\importlib\__init__.py", line 127, in impor
t_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Program Files\Python38\lib\site-packages\sqlserver_ado\base.py", line
13, in <module>
from . import dbapi as Database
File "C:\Program Files\Python38\lib\site-packages\sqlserver_ado\dbapi.py", lin
e 750, in <module>
Binary = six.memoryview
AttributeError: module 'six' has no attribute 'memoryview'
I check the six module, and yes, it doesn't include a single word named "memoryview".我检查了六个模块,是的,它不包含一个名为“memoryview”的单词。 But why the dbapi.py include the code "
Binary = six.memoryview
"?但是为什么 dbapi.py 包含代码“
Binary = six.memoryview
”? And I search "six.memoryview" on Google.So many results but I can't understand.我在 Google 上搜索“six.memoryview”。结果很多,但我看不懂。
The django-mssql
package hasn't been updated in years, and will not work with any currently supported version of Django. django-mssql
package 多年未更新,并且不适用于任何当前支持的 Django 版本。 The package you will want to use for current versions of Django is django-mssql-backend
:您将要用于当前版本的 Django 的 package 是
django-mssql-backend
:
https://pypi.org/project/django-mssql-backend/ https://pypi.org/project/django-mssql-backend/
This package supports both Django 2.2, and Django 3.0, the currently supported versions as of this writing.此 package 支持 Django 2.2 和 Django 3.0,即撰写本文时当前支持的版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.