[Django]显示错误配置的错误“需要SQLite 3.8.3或更高版本(找到3.7.17)”,但在manage.py runserver中正常工作

时间:2019-06-10 04:50:30

标签: django sqlite deployment mod-wsgi subdirectory

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

我试图在CentOS Web服务器上部署一个具有基本模块和“ hello world”首页的网站。但是,引发了内部服务器错误,仅在www.example.com上的Web冲浪(端口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):

无论在根环境和虚拟环境中,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).

1 个答案:

答案 0 :(得分:1)

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

  1. 简单的方法就是将Django降级到OS软件包可以满足要求的2.1.2

  2. 使用必需的sqlite依赖项编译Python3。