在centos进行Django项目部署时,出现的sqlite版本问题小记
在创建django应用或使用python manage.py runserver
时如果报以下错误:django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required。个人的版本情况为:1.python:3.9.10 ; 2.django3.2
这样的问题的解决方法有:
- 方法一:通过降低Django版本去解决,结果实践证明不行。
- 方法二:升级sqlite.
下载地址:
1 | https: / / www.sqlite.org / download.html: |
1 2 3 4 5 6 | cd / usr / local / src wget http: / / www.sqlite.org / 2021 / sqlite - autoconf - 3360000.tar .gz tar - zxvf sqlite - autoconf - 3360000.tar .gz cd sqlite - autoconf - 3360000 . / configure - - prefix = / usr / local / sqlite make && make install |
2.替换旧的版本:
1 2 3 | mv / usr / bin / sqlite3 / usr / bin / sqlite3_bak cd / usr / local / sqlite / bin / ln - s sqlite3 / usr / bin / sqlite3 |
3.根据sql安装路径填写,并让配置生效:
1 2 3 4 | [root@test ~] vim / etc / profile #添加内容 export LD_LIBRARY_PATH = "/usr/local/sqlite/lib" [root@test ~]source / etc / profile |
4.查看版本:发现已经更新成功:
1 2 3 | >>> import sqlite3 >>> sqlite3.sqlite_version '3.36.0' |
本以为OK了,结果还是不行。
1 2 3 | python3 manage.py runserver #....省略 django.db.utils.NotSupportedError: deterministic = True requires SQLite 3.8 . 3 |
到底如何去解决呢?试了试第三种方法。
- 方法三:使用 pysqlite3 和 pysqlite3-binary 库来操作。
首先下载下pysqlite3和pysqlite3-binary库
1 2 | pip3 install pysqlite3 pip3 install pysqlite3 - binary |
然后更改下,....../sqlite3/base.py,每个人安装路径不一样,自己找。
1 2 3 | [root@test ~]vim / opt / python3910 / lib / python3. 9 / site - packages / django / db / backends / sqlite3 / base.py #修改内容 #from sqlite3 import dbapi2 as Database (注释掉这段) from pysqlite3 import dbapi2 as Database #改成pysqlite3 |
这样就OK了。
1 | python3 manage.py runserver 0 : 8080 #(用0代替0.0.0.0) |
好了,到此问题已解决!!!
分类:
centos
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下