django.core.exceptions.ImproperlyConfigured: SQLite 3.9.0 or later is required (found 3.7.17).

坑爹的玩意,centos自带的是3.7.17 django版本就不支持,必须要3.9.0以上,如果要使用sqlite3作为数据库,那就没办法,升吧,如果换作我,我就不用sqlite3,用mysql

升级也简单:

1. 下载sqlite3的最新包

https://www.sqlite.org/download.html

wget https://www.sqlite.org/2021/sqlite-autoconf-3350500.tar.gz

2. 编译安装

tar xf https://www.sqlite.org/2021/sqlite-autoconf-3350500.tar.gz
cd sqlite-autoconf-3350500
./configure --prefix=/usr/local/ && make && make install 
# 命令都很简单,就不用解释了吧

3. 改一下原有的sqlite3的命令

先查一下sqlite3在哪个目录下有可执行文件

(python36) [root@george servermonitor]# whereis sqlite3
 sqlite3: /usr/bin/sqlite3 /usr/local/bin/sqlite3 /usr/include/sqlite3.h /usr/share/man/man1/sqlite3.1.gz (python36) [root@george servermonitor]#

查到 /usr/bin/sqlite3 是老的,3.7.17的,不确定,你就执行一下就知道了

/usr/bin/sqlite3 --verssion

那替换掉这个老版本的

mv /usr/bin/sqlite3 /usr/bin/sqlite3_3.7.17 别太暴力删除,怕还要恢复呢,是吧,留后手
 ln -s /usr/local/bin/sqlite3 /usr/bin/sqlite3

4. 改库路径

很多小伙伴到上面,就去测了,发现执行python manage.py runserver 8080还是报相同的错误,原因啊,是因为django读的还是老的库,自已也可以验证一下

(python36) [root@george servermonitor]# python 
Python 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 
(Red Hat 4.8.5-44)] on linux Type "help", "copyright", "credits" or "license" for more information.
 >>> import sqlite3
 > >>> sqlite3.sqlite_version 
 > '3.7.17'      # 还是老的,坑爹
>>> .exit

修改库变量

export LD_LIBRARY_PATH="/usr/local/lib/"

再测试

(python36) [root@george servermonitor]# python Python 3.6.8
 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux Type "help", "copyright", "credits" or "license" for more information.
  >>> import sqlite3
  > >>> sqlite3.sqlite_version
  '3.35.5'          # 版本升级成功 
  >>> exit()

执行恢复正常

(python36) [root@george servermonitor]# python manage.py runserver 8080
 Django version 3.2.4, using settings 'servermonitor.settings' Starting development server at
http://127.0.0.1:8080/ Quit the server with CONTROL-C.

你可能感兴趣的:(python)