Wagtail 2.0全新安装执行python manage.py migrate报错求助
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 --versionin your virtualenv, thenpip show wagtailto confirm the installed Wagtail version. Cross-reference against Wagtail's version-specific Python requirements.
- Quick checks: Run
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 withpip install wagtail, then re-runwagtail start mysiteandpython manage.py migrate. This eliminates issues with your existing env.
- Try this: Create a new env with
Leftover Transitive Dependencies
Uninstalling Wagtail/Django doesn't always remove every dependency they rely on (likedjango-modelclusterordjango-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.- Do a full cleanup:
Corrupted SQLite Database
By default, Wagtail uses SQLite. If a previous failed run left a corrupteddb.sqlite3file, or you accidentally tweaked the database settings insettings.py, migrate will fail.- Fix steps: Delete the
db.sqlite3file in your project directory, double-check that theDATABASESsection insettings.pyuses the default SQLite config (no typos), then re-runmigrate.
- Fix steps: Delete the
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 -lain 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.
- On macOS/Linux: Run
内容的提问来源于stack exchange,提问作者brunam

