SQLite 3.8.3 or later is required (found 3.6.20).

在Centos环境下部署Django项目的时候出现如下错误:
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.6.20).
百度了一下出现错误的原因,大概是Centos系统自带的sqlite3版本偏低,在上面的错误提示中要求需要SQLite 3.8.3 or later,那么就需要去升级 SQlite 的版本了。
解决方法有两种,一是升级SQLite ,二是降低django的版本,我采用的是降低Django的版本,这个比较有效。
方法1:降低Django的版本
  前提是需要进入你创建的Django的虚拟环境进行安装

(mysite) [root@localhost env]# pip3 uninstall django
(mysite) [root@localhost env]# pip3 install django==2.1.8

方法2:升级SQLite

[root@localhost /]#  sqlite3 --version
[root@localhost /]# wget https://www.sqlite.org/2019/sqlite-autoconf-3270200.tar.gz
[root@localhost /]# tar -zxvf sqlite-autoconf-3270200.tar.gz
[root@localhost /]# cd sqlite-autoconf-3270200
[root@localhost /]# ./configure --prefix=/usr/local
[root@localhost /]# make 
[root@localhost /]# make install
[root@localhost /]# find /usr/ -name sqlite3
#检查版本
## 最新安装的sqlite3版本
[root@localhost /]## /usr/local/bin/sqlite3 --version
3.27.2 2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0f6d7
[root@localhost /]# 
 
## Centos7自带的sqlite3版本
[root@localhost /]# /usr/bin/sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668
[root@djangoServer ~]# 
 
## 可以看到sqlite3的版本还是旧版本,那么需要更新一下。
[root@localhost /]# sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668
[root@localhost /]#
 
## 更改旧的sqlite3
[root@localhost /]# mv /usr/bin/sqlite3  /usr/bin/sqlite3_old
 
## 软链接将新的sqlite3设置到/usr/bin目录下
[root@localhost /]# ln -s /usr/local/bin/sqlite3   /usr/bin/sqlite3
 
## 查看当前全局sqlite3的版本
[root@localhost /]# sqlite3 --version
3.27.2 2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0f6d7
[root@localhost /]#
 
#将路径传递给共享库
# 设置开机自启动执行,可以将下面的export语句写入 ~/.bashrc 文件中,如果如果你想立即生效,可以执行source 〜/.bashrc 将在每次启动终端时执行
[root@localhost /]# export LD_LIBRARY_PATH="/usr/local/lib"
 
#检查Python的SQLite3版本
[root@localhost /]#  ipython3
Python 3.7.1 (default, May  3 2019, 09:55:04) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.
 
In [1]: import sqlite3                                                     
 
In [2]: sqlite3.sqlite_version                                             
Out[2]: '3.27.2'
 
In [3]: exit                                                               
[root@localhost /]#
#启动开发服务器
(mysite) [root@localhost myblog]# python3 manage.py runserver
发布了56 篇原创文章 · 获赞 50 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_43883625/article/details/100709484