报错(SQLite 3.8.3 or later is required (found 3.7.17).)的解决办法
在服務(wù)器上剛部署完Django項(xiàng)目,python manage.py runserver 0.0.0.0:8000啟動(dòng)啟動(dòng)的時(shí)候報(bào)錯(cuò):django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).,以下為報(bào)錯(cuò)展示及解決辦法。
目錄
- 一、報(bào)錯(cuò)演示
- 二、問題解決
一、報(bào)錯(cuò)演示
(venv) [root@localhost celery]# python manage.py runserver 0.0.0.0:8000 Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last):File "/usr/local/python3/lib/python3.6/threading.py", line 916, in _bootstrap_innerself.run()File "/usr/local/python3/lib/python3.6/threading.py", line 864, in runself._target(*self._args, **self._kwargs)File "/home/celery/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapperfn(*args, **kwargs)File "/home/celery/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_runautoreload.raise_last_exception()File "/home/celery/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 76, in raise_last_exceptionraise _exception[1]File "/home/celery/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in executeautoreload.check_errors(django.setup)()File "/home/celery/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapperfn(*args, **kwargs)File "/home/celery/venv/lib/python3.6/site-packages/django/__init__.py", line 24, in setupapps.populate(settings.INSTALLED_APPS)File "/home/celery/venv/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populateapp_config.import_models()File "/home/celery/venv/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_modelsself.models_module = import_module(models_module_name)File "/home/celery/venv/lib/python3.6/importlib/__init__.py", line 126, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File "<frozen importlib._bootstrap>", line 994, in _gcd_importFile "<frozen importlib._bootstrap>", line 971, in _find_and_loadFile "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 665, in _load_unlockedFile "<frozen importlib._bootstrap_external>", line 678, in exec_moduleFile "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removedFile "/home/celery/venv/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in <module>from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManagerFile "/home/celery/venv/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 47, in <module>class AbstractBaseUser(models.Model):File "/home/celery/venv/lib/python3.6/site-packages/django/db/models/base.py", line 121, in __new__new_class.add_to_class('_meta', Options(meta, app_label))File "/home/celery/venv/lib/python3.6/site-packages/django/db/models/base.py", line 325, in add_to_classvalue.contribute_to_class(cls, name)File "/home/celery/venv/lib/python3.6/site-packages/django/db/models/options.py", line 208, in contribute_to_classself.db_table = truncate_name(self.db_table, connection.ops.max_name_length())File "/home/celery/venv/lib/python3.6/site-packages/django/db/__init__.py", line 28, in __getattr__return getattr(connections[DEFAULT_DB_ALIAS], item)File "/home/celery/venv/lib/python3.6/site-packages/django/db/utils.py", line 207, in __getitem__backend = load_backend(db['ENGINE'])File "/home/celery/venv/lib/python3.6/site-packages/django/db/utils.py", line 111, in load_backendreturn import_module('%s.base' % backend_name)File "/home/celery/venv/lib/python3.6/importlib/__init__.py", line 126, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File "/home/celery/venv/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 68, in <module>check_sqlite_version()File "/home/celery/venv/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 65, in check_sqlite_versionraise 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.7.17).二、問題解決
按照習(xí)慣,翻譯一下報(bào)錯(cuò)信息
大致意思是:Django需要SQLite 3.8.3或更高版本,而現(xiàn)在的版本為3.7.17
兩個(gè)解決辦法
方法一:給Django降級
如果是生產(chǎn)環(huán)境或者項(xiàng)目規(guī)定了Django版本,那么降級Django會(huì)引起一系列的問題,本人建議使用方法二,慎重慎重,當(dāng)然測試環(huán)境就無所謂了。
卸載Django
pip uninstall django安裝低版本,版本號(hào)根據(jù)自身項(xiàng)目選擇合適的
pip install django==2.1.7方法二:升級SQLite
(1)獲取安裝包下載鏈接
下載地址:https://www.sqlite.org/download.html
最好重新獲取一下下載鏈接,否則可能不是最新版(以上截圖為本人寫此篇文章時(shí)候的最新版)
(2)wget下載
#鏈接最好重新獲取,否則可能不是最新版本 wget https://www.sqlite.org/2019/sqlite-autoconf-3300100.tar.gz(3)解壓并安裝
[root@localhost home]# tar zxvf sqlite-autoconf-3300100.tar.gz [root@localhost home]# cd sqlite-autoconf-3300100/ [root@localhost sqlite-autoconf-3300100]# ./configure [root@localhost sqlite-autoconf-3300100]# make & make install(4)查看版本
#檢查新安裝的sqlite3版本 [root@localhost home]# /usr/local/bin/sqlite3 --version 3.30.1 2019-10-10 20:19:45 18db032d058f1436ce3dea84081f4ee5a0f2259ad97301d43c426bc7f3df1b0b#檢查舊的sqlite3版本 [root@localhost home]# /usr/bin/sqlite3 --version 3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668# 把舊的sqlite3改個(gè)名字 [root@localhost home]# mv /usr/bin/sqlite3 /usr/bin/sqlite3_old# 設(shè)置軟鏈接 [root@localhost home]# ln -s /usr/local/bin/sqlite3 /usr/bin/sqlite3#查看sqlite3版本 [root@localhost home]# sqlite3 --version 3.30.1 2019-10-10 20:19:45 18db032d058f1436ce3dea84081f4ee5a0f2259ad97301d43c426bc7f3df1b0b(5)設(shè)置開機(jī)自啟動(dòng)
# 設(shè)置開機(jī)自啟動(dòng) [root@localhost home]# export LD_LIBRARY_PATH="/usr/local/lib"(6)檢查Python的SQLite3版本
[root@localhost home]# python3 Python 3.6.5 (default, Jul 9 2019, 20:03:55) [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.30.1' >>> exit() [root@localhost home]#(7)完成
如果你使用虛擬環(huán)境啟動(dòng)的項(xiàng)目,可能還會(huì)繼續(xù)報(bào)錯(cuò),需要把虛擬環(huán)境刪除,重新創(chuàng)建即可
友情提示:可以先生成依賴文件,然后一會(huì)批量導(dǎo)入。
可能用到的命令:
歡迎留言吐槽
總結(jié)
以上是生活随笔為你收集整理的报错(SQLite 3.8.3 or later is required (found 3.7.17).)的解决办法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: FPGA的UART信息回显
- 下一篇: IBM宣布关闭新加坡工厂,裁员70%