You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Wagtail 2.0全新安装执行python manage.py migrate报错求助

Troubleshooting Fresh Wagtail migrate Errors

Hey there! Let's walk through the most likely culprits for this issue—even with a clean reinstall, fresh setups can hit snags for a few common reasons:

  • Python Version Mismatch
    Wagtail ties itself to specific Python versions (e.g., Wagtail 5.x works with 3.8–3.11, 6.x needs 3.9–3.12). If your virtualenv's Python version is outside the supported range for the Wagtail version you installed, it can cause cryptic migrate failures.

    • Quick checks: Run python --version in your virtualenv, then pip show wagtail to confirm the installed Wagtail version. Cross-reference against Wagtail's version-specific Python requirements.
  • Corrupted Virtual Environment
    Sometimes virtualenvs get borked with leftover cached files or broken symlinks, even after uninstalling packages. A fresh env is often the fastest fix.

    • Try this: Create a new env with mkvirtualenv wagtail-clean, install Wagtail with pip install wagtail, then re-run wagtail start mysite and python manage.py migrate. This eliminates issues with your existing env.
  • Leftover Transitive Dependencies
    Uninstalling Wagtail/Django doesn't always remove every dependency they rely on (like django-modelcluster or django-taggit). Outdated leftover versions can clash with fresh installs.

    • Do a full cleanup:
      pip uninstall -y wagtail django django-modelcluster django-taggit wagtail-admin wagtail-core wagtail-snippets wagtail-images wagtail-documents wagtail-contrib-settings
      pip cache purge
      

    Then reinstall Wagtail cleanly with pip install wagtail.

  • Corrupted SQLite Database
    By default, Wagtail uses SQLite. If a previous failed run left a corrupted db.sqlite3 file, or you accidentally tweaked the database settings in settings.py, migrate will fail.

    • Fix steps: Delete the db.sqlite3 file in your project directory, double-check that the DATABASES section in settings.py uses the default SQLite config (no typos), then re-run migrate.
  • Directory Permission Issues
    If your user doesn't have write access to the project folder, the migrate command can't create the database file or write migration logs.

    • On macOS/Linux: Run ls -la in the project directory to check permissions—ensure your user owns the folder and has write access.
    • On Windows: Right-click the project folder, go to Properties > Security and confirm your user has read/write permissions.

内容的提问来源于stack exchange,提问作者brunam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 09:09:14