Introduction #
On some operating systems (e.g., CentOS 7), running SmartChart with SQLite3 may encounter version incompatibility errors. This is because the system’s built-in SQLite3 version is too low — Django requires SQLite 3.8.3 or later.
Error Message #
django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).
Solution Comparison #
| Solution | Difficulty | Use Case | Recommended |
|---|---|---|---|
| Upgrade system SQLite3 | Medium | General | Good |
| Use pysqlite3 replacement | Simple | Quick fix | Best |
Solution 1: Upgrade System SQLite3 #
From StackOverflow:
- Download new SQLite3 version:
wget https://www.sqlite.org/2019/sqlite-autoconf-3290000.tar.gz
- Extract:
tar zxvf sqlite-autoconf-3290000.tar.gz
- Enter directory:
cd sqlite-autoconf-3290000
- Configure install path:
./configure --prefix=$HOME/opt/sqlite
- Build and install:
make && make install
- Set environment variables:
export PATH=$HOME/opt/sqlite/bin:$PATH
export LD_LIBRARY_PATH=$HOME/opt/sqlite/lib
export LD_RUN_PATH=$HOME/opt/sqlite/lib
Verify with sqlite3 --version.
Solution 2: Use pysqlite3 Replacement (Recommended) #
If upgrading system SQLite3 still fails, use this quick fix:
# Install
pip3 install pysqlite3
pip3 install pysqlite3-binary
# Edit Django's file (path shown in error message)
vi xxxxxx/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py
# Change:
# from sqlite3 import dbapi2 as Database # Comment this out
from pysqlite3 import dbapi2 as Database
# Save and exit: :wq!