gpt4 book ai didi

python - 启动服务器时 Django 中的 _DeadlockError

转载 作者:太空狗 更新时间:2023-10-30 01:24:38 25 4
gpt4 key购买 nike

很多次我在启动 python 服务器时遇到这个错误。当我更改任何文件并且服务器再次启动时,也会发生这种情况。

我已尝试删除环境并重新创建环境,但仍然存在相同的错误。

Python 3.5.2 (default, Nov 12 2018, 13:43:14) [GCC 5.4.0 20160609] on linux

Django: 2.2.1

/home/satyam/Code/myproject/myproject_apps/invoice/services/excel_service.py changed, reloading.
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
File "/home/satyam/Code/environments/ebapps/lib/python3.5/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 "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/django/core/management/base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/django/core/management/base.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/django/contrib/admin/checks.py", line 79, in check_dependencies
for engine in engines.all():
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/django/template/utils.py", line 90, in all
return [self[alias] for alias in self]
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/django/template/utils.py", line 90, in <listcomp>
return [self[alias] for alias in self]
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/django/template/utils.py", line 81, in __getitem__
engine = engine_cls(params)
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/django/template/backends/django.py", line 25, in __init__
options['libraries'] = self.get_templatetag_libraries(libraries)
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/django/template/backends/django.py", line 43, in get_templatetag_libraries
libraries = get_installed_libraries()
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/django/template/backends/django.py", line 108, in get_installed_libraries
for name in get_package_libraries(pkg):
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/django/template/backends/django.py", line 121, in get_package_libraries
module = import_module(entry[1])
File "/home/satyam/Code/environments/ebapps/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/rest_framework/templatetags/rest_framework.py", line 15, in <module>
from rest_framework.renderers import HTMLFormRenderer
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/rest_framework/renderers.py", line 20, in <module>
from django.test.client import encode_multipart
File "/home/satyam/Code/environments/ebapps/lib/python3.5/site-packages/django/test/client.py", line 23, in <module>
from django.test import signals
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 168, in __enter__
File "<frozen importlib._bootstrap>", line 110, in acquire
_frozen_importlib._DeadlockError: deadlock detected by _ModuleLock('django.test.signals') at 140078699689688

最佳答案

导致我出错的是这个导入:

from rest_framework.urlpatterns import format_suffix_patterns

删除它立即解决了问题。

关于python - 启动服务器时 Django 中的 _DeadlockError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56372727/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com