当前位置:首页 > 数据库 > SQlite

Centos7 虚拟环境安装Django 出现ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).&#039

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).' - 文章图片

 

 

 

解决方法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

 

[root@hsz ~]#

 

 

 

#将路径传递给共享库

 

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

 

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

 

 

 

# 查看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'

 

>>>

 

 

 

如果这种情况出现在虚拟环境中,暂时没有找到别的方法,只有先把本地环境的sqlite3更新,然后重新建立一个虚拟环境,来替代原来的虚拟环境,因为sqlite3 是python中自带的.

 


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!