在使用 Python 3.7.2 的虚拟环境中,我尝试运行 django 的 python manage.py startap myapp
并且我收到此错误:
raise ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' % Database.sqlite_version)
django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.8.2).
我正在运行 Ubuntu Trusty 14.04 服务器。
如何将我的 sqlite 版本升级或更新到 >=3.8.3?
我跑了
$ apt list --installed | grep sqlite
libaprutil1-dbd-sqlite3/trusty,now 1.5.3-1 amd64 [installed,automatic]
libdbd-sqlite3/trusty,now 0.9.0-2ubuntu2 amd64 [installed]
libsqlite3-0/trusty-updates,trusty-security,now 3.8.2-1ubuntu2.2 amd64 [installed]
libsqlite3-dev/trusty-updates,trusty-security,now 3.8.2-1ubuntu2.2 amd64 [installed]
python-pysqlite2/trusty,now 2.6.3-3 amd64 [installed]
python-pysqlite2-dbg/trusty,now 2.6.3-3 amd64 [installed]
sqlite3/trusty-updates,trusty-security,now 3.8.2-1ubuntu2.2 amd64 [installed]
和
sudo apt install --only-upgrade libsqlite3-0
Reading package lists... Done
Building dependency tree
Reading state information... Done
libsqlite3-0 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
编辑: settings.py
是股票标准:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
原文由 Chubeez 发布,翻译遵循 CC BY-SA 4.0 许可协议
如果你不想重新编译 Python 并且你正在使用 virtualenv,你可以这样做来设置它而不影响整个系统(我已经用 Ubuntu 16⁄18 完成了这个):
从 https://www.sqlite.org/download.html 下载 SQLite tarball
将内容和 cd 提取到文件夹中。
运行以下命令:
。/配置
须藤安装
activate
用于启动 virtualenv 的脚本,以便 Python 在正确的位置查找新安装的 SQLite。将以下行添加到/path/to/virtualenv/bin/activate
的顶部:导出 LD_LIBRARY_PATH=“/usr/local/lib”
现在,当处于活动状态时,Django 2.2+ 应该可以在 virtualenv 中正常工作。希望有所帮助。