[Django] 显示配置不当错误 "SQLite 3.8.3 or later is required (found 3.7.17)",但在 manage.py runserver 中工作正常

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

请帮助提供将 wsgi 或 apache 定向到正确的 sqlite3 库的任何想法。

我试图在 CentOS 网络服务器上部署一个具有基本模块和 "hello world" 首页的网站。然而,出现了内部服务器错误,并且只发生在 www.example.com 的网上冲浪(端口 80)中。当调用 "python3 manage.py runserver" 时(Django 版本:2.2.2)(端口 8000)运行良好。以上是错误的详细信息,是关于需要SQLite 3.8.3或更高版本的错误版本(找到3.7.17)。

我以前重装过sqlite3,没用。将 base.py 的内容更改为以下命令时,可以访问 hello world 站点,而管理页面出现故障(可能是由于其他问题......)。但是硬编码并不健康...

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

无论是root环境还是虚拟环境,python2和python3都可以打开3.28.0

版本的sqlite3
(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'
>>>

httpd.conf中相关的代码是

=====
#<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>
====

当访问 www.example.com/app 时它引发了

内部服务器错误 服务器遇到内部错误或配置错误,无法完成您的请求。


这是 httpd 日志错误详细信息:

[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).

这是 Ubuntu/Debian 依赖项的问题,当前稳定版中的 python 构建未与 Django 2.2 的 sqlite 要求保持同步。有两种解决方案:

  1. 简单的方法就是将 Django 降级到 2.1.2,其中 OS 包

  2. 满足要求
  3. 使用所需的 sqlite 依赖项编译 Python3。