各版本信息: python版本
[root@test ~] python3 --version
Python 3.8.5
Django版本:
>>> import django
>>> django.get_version()
'3.2.7'
sqlite3版本:
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.6.20'
启动报错:
[root@test ~] python3 manage.py runserver
....
django.core.exceptions.ImproperlyConfigured: SQLite 3.9.0 or later is required (found 3.7.17)
通过报错知道是sqlite的版本过低的问题: 下载地址 https://www.sqlite.org/download.html 1.更新版本:
cd /usr/local/src
wget http://www.sqlite.org/2021/sqlite-autoconf-3360000.tar.gz
tar -zxvf sqlite-autoconf-3360000.tar.gz
cd sqlite-autoconf-3360000
./configure --prefix=/usr/local/sqlite
make && make install
2.替换旧的版本:
mv /usr/bin/sqlite3 /usr/bin/sqlite3_bak
cd /usr/local/sqlite/bin/
ln -s sqlite3 /usr/bin/sqlite3
3.根据sql安装路径填写,并让配置生效:
[root@test ~] vim /etc/profile
export LD_LIBRARY_PATH="/usr/local/sqlite/lib"
[root@test ~]source /etc/profile
4.查看版本:发现已经更新成功:
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.36.0'
继续启动,又报了新的错误(我裂了):
python3 manage.py runserver
django.db.utils.NotSupportedError: deterministic=True requires SQLite 3.8.3
1.可能是版本之间有些特性不支持,那就不用系统提供的sqlite3了, 使用 pysqlite3 和 pysqlite3-binary 库来操作:
pip3 install pysqlite3
pip3 install pysqlite3-binary
2.修改db代码导入库
[root@test ~] vim /usr/local/python3/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py
from pysqlite3 import dbapi2 as Database
3.启动成功:
python3 manage.py runserver 0:666
|