django can't find new sqlite version? (SQLite 3.8.3 or later is required (found 3.7.17))

后端 未结 9 1473
既然无缘
既然无缘 2020-12-08 10:18

I\'ve cloned a django project to a Centos 7 vps and I\'m trying to run it now, but I get this error when trying to migrate:

$ python manage.py m         


        
相关标签:
9条回答
  • 2020-12-08 10:40

    django 2.2 need sqlite version >= 3.8.3

    so the solution is update your sqlite:

    1. download from sqlite3, select source_code version
    2. tar -zxvf sqlite-xxx.tar.gz && cd xx
    3. ./configure && make && make install
    4. mv /usr/bin/sqlite3 /usr/bin/sqlite3.bak
    5. mv xxx/sqlite3 /usr/bin/sqlite3
    6. export LD_LIBRARY_PATH="/usr/local/lib" and write it into ~/.bashrc

    test1 :

    sqlite3 --version 
    

    should be your version

    test2:

    $python
    >>> import sqlite3
    >>> sqlite3.sqlite_version
    

    should be your version

    0 讨论(0)
  • 2020-12-08 10:46

    another option is to use atomic repo

    wget -O - http://updates.atomicorp.com/installers/atomic |sh
    yum install  atomic-sqlite
    LD_LIBRARY_PATH='/opt/atomicorp/atomic/root/usr/lib64/' python3
    >>> import sqlite3
    >>> sqlite3.sqlite_version
    '3.8.5'
    
    0 讨论(0)
  • 2020-12-08 10:52

    To check which version of SQLite Python is using:

    $ python
    Python 3.7.3 (default, Apr 12 2019, 16:23:13) 
    >>> import sqlite3
    >>> sqlite3.sqlite_version
    '3.27.2'
    

    For me the new version of sqlite3 is in /usr/local/bin so I had to recompile Python, telling it to look there:

    sudo LD_RUN_PATH=/usr/local/lib ./configure --enable-optimizations
    sudo LD_RUN_PATH=/usr/local/lib make altinstall
    

    I hope that helps.

    0 讨论(0)
  • 2020-12-08 10:52

    Sorry everyone for being quiet. I didn't understand servers back then so I decided to stay out of it.

    But personally I switched to PostgreSQL to make my website work.

    0 讨论(0)
  • 2020-12-08 10:53

    I solved a similar situation with the following patches of code. Follow these steps that I used on my own centos7 & everything should be alright. Just remember to let your centos7 know that you are calling python3 not just python otherwise it will call the default python2 followed by a series of errors in your virtualenv.

    Installing python3 (from source):

    cd ~
    wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
    tar xJf Python-3.7.3.tar.xz
    cd Python-3.7.3
    ./configure
    make && make install
    export PATH=$HOME/opt/python-3.7.3/bin:$PATH
    

    Then run: source .bash_profile

    Confirming by

    python3 --version
    Python 3.7.3 
    

    Installing your sqlite3 (from source):

    $ cd ~
    $ wget https://www.sqlite.org/2019/sqlite-autoconf-3290000.tar.gz
    $ tar zxvf sqlite-autoconf-3290000.tar.gz
    cd sqlite-autoconf-3290000
    
    $./configure --prefix=$HOME/opt/sqlite
    $ make && make install
    

    Now this is what you should also remember to do for centos7 know where to look for your python3 and not defaulting to python2. On your .bash_profile copy & past this piece of code or edit the paths accordingly:

    export PATH=$HOME/opt/sqlite/bin:$PATH
    export LD_LIBRARY_PATH=$HOME/opt/sqlite/lib
    export LD_RUN_PATH=$HOME/opt/sqlite/lib
    

    Make it permanent by running: source .bash_profile and you are done with sqlite3 version >= 3.8. Confirm it by:

    sqlite3 --version 
    3.29.0 2019-07-10 17:32:03
    

    And then you can continue to use python3 to install python3 modules like django-2.2.

    python3.7 -m pip3 install virtualenv
    
    (myvenv37)[me@test my_project]$ python3.7 -m pip3 install django
    Successfully installed django-2.2.3 pytz-2019.1 sqlparse-0.3.0
    

    Remember, it is

    PYTHON3.7 -m pip3 install MODULE

    (myvenv37)[me@test my_project]$ python3.7 manage.py runserver 
    

    and the server should be running.

    So, to conclude, in the case above it was migrate, & should look like this:

    (venv)[me@test my_project]$ python3.7 manage.py migrate
    
    0 讨论(0)
  • 2020-12-08 10:58

    As this was about Centos7, you can use the Fedora package to upgrade the Centos sqlite package:

    wget https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-3.8.11-1.fc21.x86_64.rpm
    
    sudo yum install sqlite-3.8.11-1.fc21.x86_64.rpm
    

    (from: https://www.reddit.com/r/linuxadmin/comments/c9hy5w/trying_to_upgrade_sqlite_3717_to_version_38_on/ezrtbkm/?utm_source=reddit&utm_medium=web2x&context=3)

    This seems to work, although I'm never sure if doing this is really an ideal solution to a problem or not. I guess if you're not actually using SQLite, then this at least passes the version check and so gets you working.

    0 讨论(0)
提交回复
热议问题