Centos7 虚拟环境安装Django 出现ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' %Database.sqlite_version)错误

时间:2022-09-30 15:48:30

Centos7 虚拟环境安装Django 出现SQLite版本问题

raise ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' %Database.sqlite_version)

报错的在运行命令添加app时候,如下图:

Centos7 虚拟环境安装Django 出现ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' %Database.sqlite_version)错误

解决方法1:给django降级

卸载django:   pip uninstall django

安装低版本:   pip install django==2.1.8

解决方法2:升级SQLite

1.查看系统的sqlte3的版本

sqlite3 --version

Centos系统自带的sqlite3版本偏低,在上面的错误提示中要求需要SQLite 3.8.3 or later,那么就需要去升级 SQlite 的版本了。

2.Centos7安装最新的sqlite3并设置更新python库版本

#更新SQLite 3

(demo1) [root@hsz opt]# wget https://www.sqlite.org/2019/sqlite-autoconf-3270200.tar.gz

(demo1) [root@hsz opt]# tar -zxvf sqlite-autoconf-3270200.tar.gz

# 编译安装

(demo1) [root@hsz opt]# cd sqlite-autoconf-3270200/

(demo1) [root@hsz sqlite-autoconf-3270200]# ./configure --prefix=/usr/local

(demo1) [root@hsz sqlite-autoconf-3270200]# make && make install

# 查找最新版与旧版及更新操作

## 查看有哪几个 sqlite3

(demo1) [root@hsz sqlite-autoconf-3270200]# find /usr/ -name sqlite3

/usr/bin/sqlite3

/usr/lib64/python2.7/sqlite3

/usr/local/bin/sqlite3

/usr/local/python3/lib/python3.6/site-packages/django/db/backends/sqlite3

/usr/local/python3/lib/python3.6/sqlite3

## 查看旧版本Centos7自带的sqlite3版本

(demo1) [root@hsz sqlite-autoconf-3270200]# /usr/bin/sqlite3 -version

3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668

## 最新安装的sqlite3版本

(demo1) [root@hsz sqlite-autoconf-3270200]# /usr/local/bin/sqlite3 -version

3.27.2 2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0f6d7

# 备份旧的sqlite3

(demo1) [root@hsz sqlite-autoconf-3270200]# mv /usr/bin/sqlite3  /usr/bin/sqlite3_old

# 软链接将新的sqlite3设置到/usr/bin目录下

(demo1) [root@hsz sqlite-autoconf-3270200]# ln -s /usr/local/bin/sqlite3   /usr/bin/sqlite3

# 查看当前全局sqlite3的版本

[root@hsz ~]# sqlite3 --version

3.27.2 2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0f6d7

#将路径传递给共享库

# 设置开机自启动执行,可以将下面的export语句写入 ~/.bashrc 文件中,如果如果你想立即生效,可以执行source ~/.bashrc 将在每次启动终端时执行

[root@djangoServer ~]# export LD_LIBRARY_PATH="/usr/local/lib"

Centos7 虚拟环境安装Django 出现ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' %Database.sqlite_version)错误

# 查看python环境中sqlite3 是否已经更新

[root@hsz ~]# python3

Python 3.6.6 (default, Sep 12 2019, 10:27:00)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> import sqlite3

>>> sqlite3.sqlite_version

'3.27.2'

>>>

如果这种情况出现在虚拟环境中,没有更新的话,重启下虚拟环境,然后运行source ~/.bashrc后再重现进入虚拟环境即可