使用Django开发过程中执行python manage.py migrate的时候报以下错误:
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.7.17).
看起来是操作系统自带的sqlite3版本太低,那就从源码编译一个最新的吧
从官网:https://sqlite.org/download.html 找到最新版的链接地址下载
wget https://sqlite.org/2021/sqlite-autoconf-3350200.tar.gz
下载后解压:
tar -xvf sqlite-autoconf-3350200.tar.gz
进入解压后的目录:
cd sqlite-autoconf-3350200
编译:
./configure; make
等待编译完成
安装:
sudo make install
从打印输出可以看到默认的安装目录是:
/usr/bin/mkdir -p '/usr/local/bin'
/bin/sh ./libtool --mode=install /usr/bin/install -c sqlite3 '/usr/local/bin'
libtool: install: /usr/bin/install -c sqlite3 /usr/local/bin/sqlite3
之前低版本的安装路径是:/usr/bin/sqlite3
可以选择删掉旧版本,也可以不用管,修改PATH环境变量,打开~/.bashrc,最后一行添加一句:
export PATH=/usr/local/bin:$PATH
使环境变量生效:
source ~/.bashrc
测试一下:
♥frank-16:47:42=>>~/tools/sqlite-autoconf-3350200$ which sqlite3
/usr/local/bin/sqlite3
返回 /usr/local/bin/sqlite3 说明ok
回去再执行下python manage.py migrate:
(venv) ♥frank-16:48:08=>>~/code/learning_log$ python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying auth.0012_alter_user_first_name_max_length... OK
Applying sessions.0001_initial... OK
搞定!