Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[Django]Showing ImproperlyConfigured error "SQLite 3.8.3 or later is required (found 3.7.17)", but work normal in manage.py runserver

Please help to provide any ideas to direct wsgi or apache to the correct sqlite3 library.

I was trying to deploy a website with basic modules and a "hello world" front page at a CentOS web server. However, internal server error was raised and only happens in web surfing (port 80) at www.example.com. The (port 8000) runs fine when "python3 manage.py runserver" is called (Django version: 2.2.2). Here above is the details of error, which is about the incorrect version of SQLite 3.8.3 or later is required (found 3.7.17).

I used to reinstall sqlite3 and not work. When changing the content of base.py to the following command, the hello world site can be reached while the admin page was malfunctional (it may be due to another issue...). But hard coding is not healthy...

if Database.sqlite_version_info < (3, 7, 3):

No matter in root environment and virtual environment, both python2 and python3 can open the sqlite3 with version 3.28.0

(venv) [root@...]# python
Python 2.7.5 (default, Apr  9 2019, 14:30:50)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.28.0'


(venv) [root@...]# python3
Python 3.6.8 (default, May  2 2019, 20:40:44)
[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.28.0'
>>>

the code related in httpd.conf is

=====
#<VirtualHost ip-address:80>
ServerName example.com
RewriteCond %{REQUEST_URI} ^/((sub_site/.*$)|(sub_site$))
RewriteRule ^ - [L]
WSGIProcessGroup newproject
WSGIDaemonProcess newproject python-home=/home/site/venv python-path=/home/site/project_name/ startup-timeout=15
WSGIPythonPath /home/site/venv/lib/python3.6/site-packages
WSGIPassAuthorization On
WSGIScriptAlias /sub_site "/home/site/project_name/project_name/wsgi.py"
       <Directory /home/site/project_name/project_name>
               <Files wsgi.py>
                       Require all granted
               </Files>
       </Directory>
#Static media, of course:
#Alias /donut/site_media/ /path/to/static/media/
Alias /media /home/site/project_name/media/
<Directory /home/site/project_name/media>
Order deny,allow
Allow from all
</Directory>
Alias /static /home/site/project_name/static/
<Directory /home/site/project_name/static>
Order deny,allow
Allow from all
</Directory>
====

when visit www.example.com/app it raised

Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.


Here is the httpd log error details:

[wsgi:error] [pid 16968:tid 140448358127360] basedir /home/site/project_name
[wsgi:error] [pid 16968:tid 140448358127360] /home/site/project_name/static
 mod_wsgi (pid=16968): Failed to exec Python script file '/home/site/project_name/project_name/wsgi.py'.
 mod_wsgi (pid=16968): Exception occurred processing WSGI script '/home/site/project_name/project_name/wsgi.py'.
Traceback (most recent call last):
File "/home/site/project_name/project_name/wsgi.py", line 19, in <module>
application = get_wsgi_application()
File "/home/site/venv/lib64/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/home/site/venv/lib64/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/site/venv/lib64/python3.6/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/site/venv/lib64/python3.6/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/site/venv/lib64/python3.6/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/home/site/venv/lib64/python3.6/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "/home/site/venv/lib64/python3.6/site-packages/django/db/models/base.py", line 117, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/home/site/venv/lib64/python3.6/site-packages/django/db/models/base.py", line 321, in add_to_class
value.contribute_to_class(cls, name)
File "/home/site/venv/lib64/python3.6/site-packages/django/db/models/options.py", line 204, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/home/site/venv/lib64/python3.6/site-packages/django/db/__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/home/site/venv/lib64/python3.6/site-packages/django/db/utils.py", line 201, in __getitem__
backend = load_backend(db['ENGINE'])
File "/home/site/venv/lib64/python3.6/site-packages/django/db/utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/site/venv/lib64/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 66, in <module>
check_sqlite_version()
File "/home/site/venv/lib64/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 63, in check_sqlite_version
raise ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' % Database.sqlite_version)
error django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).
like image 905
ronaldhaha Avatar asked Jun 10 '19 04:06

ronaldhaha


1 Answers

This is an issue with Ubuntu/Debian dependencies, the python build in current stable is not up to date with Django 2.2's sqlite requirements. There are two solutions:

  1. The simple way is just to downgrade Django to 2.1.2 where the requirements are met by the OS packages

  2. Compile Python3 with the required sqlite dependency.

like image 74
Dash Winterson Avatar answered Nov 02 '22 23:11

Dash Winterson