wagtail 没有名为 wagtail.contrib 的模块

wagtail No module named wagtail.contrib

我确实在完成后开始了 wagtail 全新安装,我想使用 python 而不是 python3

pip3 install wagtail
wagtail start wagtail02
cd wagtail02
pip3 install -r requirements.txt

当我尝试执行 python manage.py 迁移 时,我收到一条错误消息

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/lotfi/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/home/lotfi/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute
    django.setup()
  File "/home/lotfi/.local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/lotfi/.local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/home/lotfi/.local/lib/python2.7/site-packages/django/apps/config.py", line 120, in create
    mod = import_module(mod_path)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named wagtail.contrib

我没有在互联网上找到解决方案,但如果我这样做 python3 manage.py 迁移 它有效,是否有解决方案来实现它使用 python 而不是 python3

通过 运行 宁 pip3 install wagtailpip3 install -r requirements 你在 python3 下安装软件包,然后尝试 运行 它与 python2.
要在 python 的正确版本下安装,请尝试 运行ning:
python -m pip install wagtail
python -m pip install -r requirements.txt

看起来您的 python 可执行文件是 Python 2.7,Wagtail 在 2018 年放弃了对它的支持。

但是,设置 a virtual environment 将允许您将 pippython 别名重新指向您选择的任何 Python 版本 - 然后您可以安装 Wagtail该环境并使用 python 命令调用它。