skip to Main Content

`I have made Django blog. I encountered this error after deploy using Elastic Beanstalk when trying to visit my website on AWS:

Django - deterministic=True requires SQLite 3.8.3 or higher upon running python manage.py runserver

So I found this solution:

Django – deterministic=True requires SQLite 3.8.3 or higher upon running python manage.py runserver

So i understand it like this:

  1. In ubuntu terminal i type : sudo apt install python3.10-venv to install envirement

  2. Then in my Django project in Visual Studio i type python3 -m venv django_my_site to create virtual env

  3. Now i click "+" to open this env and type pip3 install pysqlite3' and 'pip3 install pysqlite3-binary

  4. After that i type python3 -m pip freeze > requirements.txt
    and i get requirements.txt file which looks like that:

asgiref==3.6.0
Django==4.1.4
Pillow==9.3.0
pysqlite3==0.5.0
pysqlite3-binary==0.5.0
sqlparse==0.4.3

Now AWS have problem with installing pysqlite3.
How to properly install pysqlite3 on AWS?
AWS log:

Encountered error while trying to install package.
pysqlite3`
    
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
      
src/blob.h:4:10: fatal error: sqlite3.h: No such file or directory
#include "sqlite3.h"
                    ^~~~~~~~~~~
compilation terminated.

LINK TO MY REPOSITORY:

https://github.com/Stanotech/my_site.git

2

Answers


  1. Chosen as BEST ANSWER

    As mike said:

    I add to requirements.tht just:

    pysqlite3-binary==0.5.0
    

    I also added in settings.py:

    __import__('pysqlite3')
    import sys
    sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
    

    before:

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': BASE_DIR / 'db.sqlite3',
        }
    }
    

  2. The error here appears to stem from the lack of the development headers for sqlite compilation in the AWS environment.

    In your ubuntu environment, the development headers likely already exist, and you can confirm that they do with something like:

    $ dpkg -l | grep sqlite
    ii  libsqlite3-0:amd64                 3.31.1-4ubuntu0.3                 amd64        SQLite 3 shared library
    ii  libsqlite3-dev:amd64               3.31.1-4ubuntu0.3                 amd64        SQLite 3 development files
    

    Since the author of pysqlite3 has provided both the source distribution and a precompiled binary version, you should only add one to the requirements file you intend to ship to Elastic Beanstalk – pysqlite-binary (https://pypi.org/project/pysqlite-binary/)

    Then you should be able to use it via import pysqlite3

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search