Django - deterministic=True 在 运行 python manage.py runserver 上需要 SQLite 3.8.3 或更高版本
Django - deterministic=True requires SQLite 3.8.3 or higher upon running python manage.py runserver
我正在 运行从 AWS 安装 linux 红帽环境。
我已按照所有说明将 sqlite3 升级到“最新”版本。
我是 运行ning python 3.9.2(并用 LD_RUN_PATH=/usr/local/lib ./configure
重新编译)和 django 版本 4.
我已经设置了一个虚拟环境来安装和运行 django。我已将激活脚本更改为包含 export LD_LIBRARY_PATH="/usr/local/lib"
运行宁python manage.py runserver
,我收到错误django.db.utils.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
。我已经打开文件 /home/ec2-user/django/django/db/backends/sqlite3/base.py
(发生错误的地方),并且在错误行之后包含一个打印语句:
print("**************************\n" +
str(Database.sqlite_version) +
"\n" + str(Database.sqlite_version_info) +
"\n**************************")
返回运行s:
**************************
3.28.0
(3, 28, 0)
**************************
**************************
3.28.0
(3, 28, 0)
**************************
请让我知道需要哪些额外信息。我在 stack
上上下搜索,找不到 pop
的正确解决方案。
提前致谢!
编辑
这是回溯:
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/home/ec2-user/django/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/ec2-user/django/django/utils/asyncio.py", 21 in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/ec2-user/django/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/sqlite3/base.py", line 210, in get_new_connection
create_deterministic_function('django_date_extract', 2, _sqlite_datetime_extract)
sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/python/lib/python/3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/opt/python39/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/home/ec2-user/django/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/ec2-user/django/django/core/management/commands/runserver.py", line 126, in inner_run
self.check_migrations()
File "/home/ec2-user/django/django/core/management/base.py", line 486, in check_migrations
executor = MigrationExecutor(connectsion[DEFAULT_DB_ALIAS])
File "/home/ec2-user/django/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/ec2-user/django/django/db/migrations/loader.py", line 53, in __init__
self.build_graph()
File "/home/ec2-user/django/django/db/migrations/loader.py", line 220, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/home/ec2-user/django/django/db/migrations/recorder.py", line 77, in applied_migrations
if self.has_table():
File "/home/ec2-user/django/django/db/migrations/recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "/home/ec2-user/django/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/base/base.py", line 259, in cursor
return self._cursor()
File "/home/ec2-user/django/django/db/backends/base/base.py", line 235, in _cursor
self.ensure_connection()
File "/home/ec2-user/django/djanog/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/ec2-user/django/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/ec2-user/django/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/ec2-user/django/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/ec2-user/django/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/sqlite3/base.py", line 210, in get_new_connection
create_deterministic_function('django_date_extract', 2, _sqlite_datetime_extract)
django.db.utils.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
目前我能想到的最好办法是进入/home/ec2-user/django/django/db/backends/sqlite3/base.py
,将get_new_connection()
中的函数变量deterministic=True
更改为deterministic=False
...
这将消除错误,但似乎是一个超级作弊的解决方案。如果有人有更好的解决方法,请告诉我。
我在 linux Centos7+python3.9.6+Django3.2.5 中遇到了同样的问题。
虽然 sqlite3 已更新为最新版本。看来这是没用的。一种解决方案是将数据库从 sqlite3 更改为 pysqlite3。
激活virtualenv后,安装pysqlite
pip3 install pysqlite3
pip3 install pysqlite3-binary
并在 base.py
中更改数据库
vim python3.9.6/site-packages/django/db/backends/sqlite3/base.py
# from sqlite3 import dbapi2 as Database # annotation
from pysqlite3 import dbapi2 as Database # import pysqlite3
重新启动 django 服务器,一切正常。
我遇到了和你一样的问题。当我尝试在 Elastic Beanstalk 上部署时。
在我的例子中,当我像这样初始化 EB CLI 时使用了 Python 3.8:
eb init -p python-3.8 django-project ⛔
在 64 位 Amazon Linux 2(默认)上 运行 它不是一个很好的 python 版本。更改为 python-3.7
eb init -p python-3.7 django-project ✅
我正在 运行从 AWS 安装 linux 红帽环境。
我已按照所有说明将 sqlite3 升级到“最新”版本。
我是 运行ning python 3.9.2(并用 LD_RUN_PATH=/usr/local/lib ./configure
重新编译)和 django 版本 4.
我已经设置了一个虚拟环境来安装和运行 django。我已将激活脚本更改为包含 export LD_LIBRARY_PATH="/usr/local/lib"
运行宁python manage.py runserver
,我收到错误django.db.utils.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
。我已经打开文件 /home/ec2-user/django/django/db/backends/sqlite3/base.py
(发生错误的地方),并且在错误行之后包含一个打印语句:
print("**************************\n" +
str(Database.sqlite_version) +
"\n" + str(Database.sqlite_version_info) +
"\n**************************")
返回运行s:
**************************
3.28.0
(3, 28, 0)
**************************
**************************
3.28.0
(3, 28, 0)
**************************
请让我知道需要哪些额外信息。我在 stack
上上下搜索,找不到 pop
的正确解决方案。
提前致谢!
编辑
这是回溯:
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/home/ec2-user/django/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/ec2-user/django/django/utils/asyncio.py", 21 in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/ec2-user/django/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/sqlite3/base.py", line 210, in get_new_connection
create_deterministic_function('django_date_extract', 2, _sqlite_datetime_extract)
sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/python/lib/python/3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/opt/python39/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/home/ec2-user/django/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/ec2-user/django/django/core/management/commands/runserver.py", line 126, in inner_run
self.check_migrations()
File "/home/ec2-user/django/django/core/management/base.py", line 486, in check_migrations
executor = MigrationExecutor(connectsion[DEFAULT_DB_ALIAS])
File "/home/ec2-user/django/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/ec2-user/django/django/db/migrations/loader.py", line 53, in __init__
self.build_graph()
File "/home/ec2-user/django/django/db/migrations/loader.py", line 220, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/home/ec2-user/django/django/db/migrations/recorder.py", line 77, in applied_migrations
if self.has_table():
File "/home/ec2-user/django/django/db/migrations/recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "/home/ec2-user/django/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/base/base.py", line 259, in cursor
return self._cursor()
File "/home/ec2-user/django/django/db/backends/base/base.py", line 235, in _cursor
self.ensure_connection()
File "/home/ec2-user/django/djanog/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/ec2-user/django/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/ec2-user/django/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/home/ec2-user/django/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/ec2-user/django/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/home/ec2-user/django/django/db/backends/sqlite3/base.py", line 210, in get_new_connection
create_deterministic_function('django_date_extract', 2, _sqlite_datetime_extract)
django.db.utils.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
目前我能想到的最好办法是进入/home/ec2-user/django/django/db/backends/sqlite3/base.py
,将get_new_connection()
中的函数变量deterministic=True
更改为deterministic=False
...
这将消除错误,但似乎是一个超级作弊的解决方案。如果有人有更好的解决方法,请告诉我。
我在 linux Centos7+python3.9.6+Django3.2.5 中遇到了同样的问题。 虽然 sqlite3 已更新为最新版本。看来这是没用的。一种解决方案是将数据库从 sqlite3 更改为 pysqlite3。 激活virtualenv后,安装pysqlite
pip3 install pysqlite3
pip3 install pysqlite3-binary
并在 base.py
中更改数据库vim python3.9.6/site-packages/django/db/backends/sqlite3/base.py
# from sqlite3 import dbapi2 as Database # annotation
from pysqlite3 import dbapi2 as Database # import pysqlite3
重新启动 django 服务器,一切正常。
我遇到了和你一样的问题。当我尝试在 Elastic Beanstalk 上部署时。 在我的例子中,当我像这样初始化 EB CLI 时使用了 Python 3.8:
eb init -p python-3.8 django-project ⛔
在 64 位 Amazon Linux 2(默认)上 运行 它不是一个很好的 python 版本。更改为 python-3.7
eb init -p python-3.7 django-project ✅