gpt4 book ai didi

python - 如何修复错误 : django. db.utils.NotSupportedError:不支持 URI

转载 作者:IT王子 更新时间:2023-10-29 00:43:24 24 4
gpt4 key购买 nike

我在 Linux 机器(在 AWS 中)的 Django 项目中使用:

  • python 3.5.1
  • Django 1.11.7

我已经为我的项目创建了虚拟环境,并且所有的依赖项都完美地安装在那里。对于数据库,我使用的是 sqlite3。有关版本详细信息,请参见下文。

>>>import sqlite3
>>>sqlite3.version
'2.6.0'
>>>sqlite3.sqlite_version_info
(3, 7, 17)

settings.py 中,DATABASES 部分如下所示:

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

在运行 runserver 时,我得到一个异常,如 sqlite3.NotSupportedError: URIs not supported ,它产生了一个错误 django.db.utils.NotSupportedError: URIs not supported,我无法修复。

我已经浏览过类似 djangoproject.com 的帖子和 google.forum ,但仍然无法理解此错误的原因。我也尝试执行 python manage.py makemigrations 但同样的错误也随之而来。

注意:在 Windows 机器上,我的项目运行良好。

请看下面的回溯:

# python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
Unhandled exception in thread started by <function check_errors.
<locals>.wrapper at 0x7f07ff09c2f0>
Traceback (most recent call last):
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/tech/poc/env/lib/python3.5/site- packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 198, in get_new_connection
conn = Database.connect(**conn_params)
sqlite3.NotSupportedError: URIs not supported

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/tech/poc/env/lib/python3.5/site-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/tech/poc/env/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 128, in inner_run
self.check_migrations()
File "/tech/poc/env/lib/python3.5/site-packages/django/core/management/base.py", line 422, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/tech/poc/env/lib/python3.5/site-packages/django/db/migrations/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "/tech/poc/env/lib/python3.5/site-packages/django/db/migrations/loader.py", line 52, in __init__
self.build_graph()
File "/tech/poc/env/lib/python3.5/site-packages/django/db/migrations/loader.py", line 209, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/tech/poc/env/lib/python3.5/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "/tech/poc/env/lib/python3.5/site-packages/django/db/migrations/recorder.py", line 52, in ensure_schema
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/base/base.py", line 254, in cursor
return self._cursor()
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/base/base.py", line 229, in _cursor
self.ensure_connection()
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/tech/poc/env/lib/python3.5/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/tech/poc/env/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/tech/poc/env/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 198, in get_new_connection
conn = Database.connect(**conn_params)
django.db.utils.NotSupportedError: URIs not supported

请帮助理解并修复此错误。堆栈中没有与此问题相关的帖子,我也没有在谷歌中找到任何相关内容。

最佳答案

我遇到了类似的问题。原来 Django 2.1 与 sqlite 3.6.20 不兼容。降级到 2.0.x 版,你应该没问题。该问题已提出并标记为“已解决的错误- wontfix”here

关于python - 如何修复错误 : django. db.utils.NotSupportedError:不支持 URI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49500117/

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