报错详情:
Unhandled exception in thread started by .wrapper at 0x000002A4F264F488>
Traceback (most recent call last):
File "F:\Projects\django_env\lib\site-packages\django\core\servers\basehttp.py", line 47, in get_internal_wsgi_application
return import_string(app_path)
File "F:\Projects\django_env\lib\site-packages\django\utils\module_loading.py", line 20, in import_string
module = import_module(module_path)
File "F:\Projects\django_env\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "F:\Projects\ttsx\ttsx\wsgi.py", line 16, in
application = get_wsgi_application()
File "F:\Projects\django_env\lib\site-packages\django\core\wsgi.py", line 14, in get_wsgi_application
return WSGIHandler()
File "F:\Projects\django_env\lib\site-packages\django\core\handlers\wsgi.py", line 151, in __init__
self.load_middleware()
File "F:\Projects\django_env\lib\site-packages\django\core\handlers\base.py", line 82, in load_middleware
mw_instance = middleware(handler)
File "F:\Projects\django_env\lib\site-packages\django\contrib\sessions\middleware.py", line 15, in __init__
engine = import_module(settings.SESSION_ENGINE)
File "F:\Projects\django_env\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 941, in _find_and_load_unlocked
File "", line 219, in _call_with_frames_removed
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'redis_sessions'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "F:\Projects\django_env\lib\site-packages\django\utils\autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "F:\Projects\django_env\lib\site-packages\django\core\management\commands\runserver.py", line 147, in inner_run
handler = self.get_handler(*args, **options)
File "F:\Projects\django_env\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 27, in get_handler
handler = super(Command, self).get_handler(*args, **options)
File "F:\Projects\django_env\lib\site-packages\django\core\management\commands\runserver.py", line 68, in get_handler
return get_internal_wsgi_application()
File "F:\Projects\django_env\lib\site-packages\django\core\servers\basehttp.py", line 57, in get_internal_wsgi_application
sys.exc_info()[2])
File "F:\Projects\django_env\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "F:\Projects\django_env\lib\site-packages\django\core\servers\basehttp.py", line 47, in get_internal_wsgi_application
return import_string(app_path)
File "F:\Projects\django_env\lib\site-packages\django\utils\module_loading.py", line 20, in import_string
module = import_module(module_path)
File "F:\Projects\django_env\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "F:\Projects\ttsx\ttsx\wsgi.py", line 16, in
application = get_wsgi_application()
File "F:\Projects\django_env\lib\site-packages\django\core\wsgi.py", line 14, in get_wsgi_application
return WSGIHandler()
File "F:\Projects\django_env\lib\site-packages\django\core\handlers\wsgi.py", line 151, in __init__
self.load_middleware()
File "F:\Projects\django_env\lib\site-packages\django\core\handlers\base.py", line 82, in load_middleware
mw_instance = middleware(handler)
File "F:\Projects\django_env\lib\site-packages\django\contrib\sessions\middleware.py", line 15, in __init__
engine = import_module(settings.SESSION_ENGINE)
File "F:\Projects\django_env\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 941, in _find_and_load_unlocked
File "", line 219, in _call_with_frames_removed
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 953, in _find_and_load_unlocked
django.core.exceptions.ImproperlyConfigured: WSGI application 'ttsx.wsgi.application' could not be loaded; Error importing module: 'No module named 'redis_sessions''
解决办法:
pip install django-redis-sessions
安装详情:
(django_env) F:\Projects\ttsx>pip install django-redis-sessions
Collecting django-redis-sessions==0.5.6
Downloading https://files.pythonhosted.org/packages/4d/09/c83ce4bc4854573b7a40446228039c3137caf26c4f818052894968142f28/django-redis-sessions-0.5.6.t
ar.gz
Requirement already satisfied: redis>=2.4.10 in f:\projects\django_env\lib\site-packages (from django-redis-sessions==0.5.6) (2.10.6)
Building wheels for collected packages: django-redis-sessions
Running setup.py bdist_wheel for django-redis-sessions ... done
Stored in directory: C:\Users\93004\AppData\Local\pip\Cache\wheels\be\4f\3e\f4163f46f28f5bf601764f9345b5aadb17af03dbc2c307f880
Successfully built django-redis-sessions
Installing collected packages: django-redis-sessions
Successfully installed django-redis-sessions-0.5.6
另外django的settings.py文件中还需要配置redis-session
# 配置session使用redis
SESSION_ENGINE = "redis_sessions.session"
SESSION_REDIS_HOST = "47.98.17.29"
SESSION_REDIS_PORT = 6379
SESSION_REDIS_DB = 0
SESSION_REDIS_PASSWORD = ""
SESSION_REDIS_PREFIX = "session"