如何解决“无法从‘livereload’导入名称‘livereload_host’”

问题描述 投票:0回答:1

更改 django 应用程序中的所有参数后输入“python manage.py livereload”时出现此错误

我正在使用 django-livereload-server

"C:\Users\ADMIN\Desktop\projects\websites\buddiestouronlines>python manage.py livereload
Traceback (most recent call last):
File "C:\Users\ADMIN\AppData\Roaming\Python\Python312\site-packages\django\template\backends\django.py", line 128, in get_package_libraries
module = import_module(entry[1])
         ^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\importlib\__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "C:\Users\ADMIN\AppData\Roaming\Python\Python312\site-packages\livereload\templatetags\livereload_tags.py", line 4, in <module>
from livereload import livereload_host, livereload_port
ImportError: cannot import name 'livereload_host' from 'livereload' (C:\Users\ADMIN\AppData\Roaming\Python\Python312\site-packages\livereload\__init__.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\ADMIN\Desktop\projects\websites\buddiestouronlines\manage.py", line 22, in <module>
main()
File "C:\Users\ADMIN\Desktop\projects\websites\buddiestouronlines\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\ADMIN\AppData\Roaming\Python\Python312\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
utility.execute()
File "C:\Users\ADMIN\AppData\Roaming\Python\Python312\site-packages\django\core\management\__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\ADMIN\AppData\Roaming\Python\Python312\site-packages\django\core\management\base.py", line 413, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\ADMIN\AppData\Roaming\Python\Python312\site-packages\django\core\management\base.py", line 454, in execute
self.check()
File "C:\Users\ADMIN\AppData\Roaming\Python\Python312\site-packages\django\core\management\base.py", line 486, in check
all_issues = checks.run_checks(
             ^^^^^^^^^^^^^^^^^^
File "C:\Users\ADMIN\AppData\Roaming\Python\Python312\site-packages\django\core\checks\registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ADMIN\AppData\Roaming\Python\Python312\site-packages\django\core\checks\templates.py", line 60, in check_for_template_tags_with_the_same_name       
for module_name, module_path in get_template_tag_modules():
File "C:\Users\ADMIN\AppData\Roaming\Python\Python312\site-packages\django\template\backends\django.py", line 105, in get_template_tag_modules
for name in get_package_libraries(pkg):
File "C:\Users\ADMIN\AppData\Roaming\Python\Python312\site-packages\django\template\backends\django.py", line 130, in get_package_libraries
 raise InvalidTemplateLibrary(
django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'livereload.templatetags.livereload_tags': cannot import name 'livereload_host' from 'livereload' (C:\Users\ADMIN\AppData\Roaming\Python\Python312\site-packages\livereload\__init__.py)"

我希望如果你能帮助我那就太好了

django live liveserver
1个回答
0
投票

0.5.1 也遇到这个问题。尝试降级到V0.5.0或更旧版本。

pip install django-livereload-server==0.5.0
© www.soinside.com 2019 - 2024. All rights reserved.