指定的模板库无效。没有名为“crispy_forms.compatibility”的模块

2024-09-10 06:57:54 发布

您现在位置:Python中文网/ 问答频道 /正文

每次我尝试使用python3 manage.py runserver在本地主机上运行django应用程序时,都会出现以下错误,我不明白为什么。我已经安装了crispy forms的最新版本(1.11.2),并将其安装在我的requirements.txt和我的venv上。有人能帮我吗

Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/utils.py", line 66, in __getitem__
    return self._engines[alias]
KeyError: 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/backends/django.py", line 121, in get_package_libraries
    module = import_module(entry[1])
  File "/Users/bermed28/opt/anaconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/crispy_forms/templatetags/crispy_forms_filters 2.py", line 9, in <module>
    from crispy_forms.compatibility import lru_cache
ModuleNotFoundError: No module named 'crispy_forms.compatibility'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/bermed28/opt/anaconda3/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/Users/bermed28/opt/anaconda3/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/core/management/base.py", line 396, in check
    databases=databases,
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/core/checks/registry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/contrib/admin/checks.py", line 78, in check_dependencies
    for engine in engines.all():
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/utils.py", line 90, in all
    return [self[alias] for alias in self]
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/utils.py", line 90, in <listcomp>
    return [self[alias] for alias in self]
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/utils.py", line 81, in __getitem__
    engine = engine_cls(params)
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/backends/django.py", line 25, in __init__
    options['libraries'] = self.get_templatetag_libraries(libraries)
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/backends/django.py", line 43, in get_templatetag_libraries
    libraries = get_installed_libraries()
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/backends/django.py", line 108, in get_installed_libraries
    for name in get_package_libraries(pkg):
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/backends/django.py", line 125, in get_package_libraries
    "trying to load '%s': %s" % (entry[1], e)
django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'crispy_forms.templatetags.crispy_forms_filters 2': No module named 'crispy_forms.compatibility'

^C%                                                                                                                                                                                                                                                    (venv) bermed28@Fernandos-MacBook-Pro semester-project-stack-overflowers % python3 manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/utils.py", line 66, in __getitem__
    return self._engines[alias]
KeyError: 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/backends/django.py", line 121, in get_package_libraries
    module = import_module(entry[1])
  File "/Users/bermed28/opt/anaconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/crispy_forms/templatetags/crispy_forms_filters 2.py", line 9, in <module>
    from crispy_forms.compatibility import lru_cache
ModuleNotFoundError: No module named 'crispy_forms.compatibility'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/bermed28/opt/anaconda3/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/Users/bermed28/opt/anaconda3/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/core/management/base.py", line 396, in check
    databases=databases,
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/core/checks/registry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/contrib/admin/checks.py", line 78, in check_dependencies
    for engine in engines.all():
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/utils.py", line 90, in all
    return [self[alias] for alias in self]
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/utils.py", line 90, in <listcomp>
    return [self[alias] for alias in self]
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/utils.py", line 81, in __getitem__
    engine = engine_cls(params)
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/backends/django.py", line 25, in __init__
    options['libraries'] = self.get_templatetag_libraries(libraries)
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/backends/django.py", line 43, in get_templatetag_libraries
    libraries = get_installed_libraries()
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/backends/django.py", line 108, in get_installed_libraries
    for name in get_package_libraries(pkg):
  File "/Users/bermed28/Desktop/semester-project-stack-overflowers/venv/lib/python3.7/site-packages/django/template/backends/django.py", line 125, in get_package_libraries
    "trying to load '%s': %s" % (entry[1], e)
django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'crispy_forms.templatetags.crispy_forms_filters 2': No module named 'crispy_forms.compatibility'

我所做的基本上是将两个分支合并,其中包括一些前端更改和后端更改,但由于这个错误,现在应用程序根本无法运行


Tags: djangoinpyprojectvenvstacklibline