Centos7 虛擬環境安裝Django 出現ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' %Database.sqlite_version)錯誤


Centos7 虛擬環境安裝Django 出現SQLite版本問題

raise ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' %Database.sqlite_version)

報錯的在運行命令添加app時候,如下圖:

 

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

 

#將路徑傳遞給共享庫

# 設置開機自啟動執行,可以將下面的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'

>>>

 

如果這種情況出現在虛擬環境中,沒有更新的話,重啟下虛擬環境,然后運行source ~/.bashrc后再重現進入虛擬環境即可

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM