解决SQLite3版本太低

问题:django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).

解决办法:

  1. 查看当前SQLite3版本:
[root@iZwz906mxhbe3mpxy6kyzoZ myblog-python]# sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668

2.如果用了虚拟环境,查看运行环境中的SQLite3版本

[root@iZwz906mxhbe3mpxy6kyzoZ myblog-python]# workon blog
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ myblog-python]# python3
Python 3.6.5 (default, Nov  8 2019, 11:56:20) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.7.17'
>>> exit()
  1. Centos7安装最新的sqlite3并设置更新python库版本
#回到根目录
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ myblog-python]# cd ~
#下载
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ ~]# wget https://www.sqlite.org/2019/sqlite-autoconf-3270200.tar.gz
#解压
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ ~]# tar -zxvf sqlite-autoconf-3270200.tar.gz
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ ~]# cd sqlite-autoconf-3270200
#配置安装路径
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ sqlite-autoconf-3270200]# ./configure --prefix=/usr/local
#安装
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ sqlite-autoconf-3270200]# make && make install
#查找SQLite3的路径
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ sqlite-autoconf-3270200]# find /usr/ -name sqlite3
#将下载解压的文件全删除
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ sqlite-autoconf-3270200]# cd ~
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ ~]# rm -rf sqlite-autoconf-3270200
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ ~]# rm -rf sqlite-autoconf-3270200.tar.gz 


#检查版本
## 最新安装的sqlite3版本
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ ~]#  /usr/local/bin/sqlite3 --version
3.27.2 2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0f6d7

## Centos7自带的sqlite3版本
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ ~]# /usr/bin/sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668

## 运行环境的sqlite3版本
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ ~]# sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668

## 更改旧的sqlite3
### 备份旧的sqlite3
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ ~]# mv /usr/bin/sqlite3  /usr/bin/sqlite3_old

## 将新的sqlite3软连接到原来sqlite3位置
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ ~]# ln -s /usr/local/bin/sqlite3   /usr/bin/sqlite3

## 运行环境的sqlite3版本
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ ~]# sqlite3 --version
3.27.2 2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0f6d7

#将路径传递给共享库
# 设置开机自启动执行,可以将下面的export语句写入 ~/.bashrc 文件中,如果如果你想立即生效,可以执行source 〜/.bashrc 将在每次启动终端时执行
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ ~]# export LD_LIBRARY_PATH="/usr/local/lib"

# 检查Python的SQLite3版本
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ ~]# python3
Python 3.6.5 (default, Nov  8 2019, 11:56:20) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3      
>>> sqlite3.sqlite_version    
'3.27.2'
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>> exit()

# 执行项目
(blog) [root@iZwz906mxhbe3mpxy6kyzoZ myblog-python]# python manage.py runserver
INFO 2019-11-09 10:27:55,169 autoreload 597 Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
November 09, 2019 - 10:27:55
Django version 2.2.5, using settings 'myblog.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

推荐阅读更多精彩内容